forked from ESAPI/esapi-java-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomizer.java
More file actions
107 lines (93 loc) · 2.81 KB
/
Copy pathRandomizer.java
File metadata and controls
107 lines (93 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
* OWASP Enterprise Security API (ESAPI)
*
* This file is part of the Open Web Application Security Project (OWASP)
* Enterprise Security API (ESAPI) project. For details, please see
* <a href="http://www.owasp.org/index.php/ESAPI">http://www.owasp.org/index.php/ESAPI</a>.
*
* Copyright (c) 2007 - The OWASP Foundation
*
* The ESAPI is published by OWASP under the BSD license. You should read and accept the
* LICENSE before you use, modify, and/or redistribute this software.
*
* @author Jeff Williams <a href="http://www.aspectsecurity.com">Aspect Security</a>
* @created 2007
*/
package org.owasp.esapi;
import org.owasp.esapi.errors.EncryptionException;
/**
* The IRandomizer interface defines a set of methods for creating
* cryptographically random numbers and strings. Implementers should be sure to
* use a strong cryptographic implementation, such as the JCE or BouncyCastle.
* Weak sources of randomness can undermine a wide variety of security
* mechanisms.
* <P>
* <img src="doc-files/Randomizer.jpg" height="600">
* <P>
* @author Jeff Williams (jeff.williams .at. aspectsecurity.com) <a
* href="http://www.aspectsecurity.com">Aspect Security</a>
* @since June 1, 2007
*/
public interface Randomizer {
/**
* Gets a random string. of a desired length and character set.
*
* @param length
* the length of the string
* @param characterSet
* the character set
*
* @return the random string
*/
String getRandomString(int length, char[] characterSet);
/**
* Returns a random boolean.
*
* @return true or false, randomly
*/
boolean getRandomBoolean();
/**
* Gets the random integer.
*
* @param min
* the minimum integer that will be returned
* @param max
* the maximum integer that will be returned
*
* @return the random integer
*/
int getRandomInteger(int min, int max);
/**
* Gets the random long.
*
* @return the random long
*/
public long getRandomLong();
/**
* Returns an unguessable random filename with the specified extension.
* @param extenstion
* extension to add to the random filename
*
* @return a random unguessable filename ending with the specified extension
*/
public String getRandomFilename( String extension );
/**
* Gets the random real.
*
* @param min
* the minimum real number that will be returned
* @param max
* the maximum real number that will be returned
*
* @return the random real
*/
float getRandomReal(float min, float max);
/**
* Generates a random GUID.
*
* @return the GUID
*
* @throws EncryptionException
*/
String getRandomGUID() throws EncryptionException;
}