Remove redundant JavaDoc in security package
- Remove all JavaDoc in security package that has no additional information than in the code - Reduce visibility of class members where appropriate
This commit is contained in:
@@ -32,7 +32,10 @@ package fr.xephi.authme.security.pbkdf2;
|
||||
*/
|
||||
public class BinTools {
|
||||
|
||||
public static final String hex = "0123456789ABCDEF";
|
||||
private static final String HEX_CHARS = "0123456789ABCDEF";
|
||||
|
||||
private BinTools() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple binary-to-hexadecimal conversion.
|
||||
@@ -49,8 +52,8 @@ public class BinTools {
|
||||
StringBuffer stringBuffer = new StringBuffer(2 * b.length);
|
||||
for (byte aB : b) {
|
||||
int v = (256 + aB) % 256;
|
||||
stringBuffer.append(hex.charAt((v / 16) & 15));
|
||||
stringBuffer.append(hex.charAt((v % 16) & 15));
|
||||
stringBuffer.append(HEX_CHARS.charAt((v / 16) & 15));
|
||||
stringBuffer.append(HEX_CHARS.charAt((v % 16) & 15));
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
@@ -58,11 +61,11 @@ public class BinTools {
|
||||
/**
|
||||
* Convert hex string to array of bytes.
|
||||
*
|
||||
* @param s String containing hexadecimal digits. May be <code>null</code>
|
||||
* . On odd length leading zero will be assumed.
|
||||
* @param s String containing hexadecimal digits. May be <code>null</code>.
|
||||
* On odd length leading zero will be assumed.
|
||||
*
|
||||
* @return Array on bytes, non-<code>null</code>. * @throws IllegalArgumentException
|
||||
* when string contains non-hex character
|
||||
* @return Array on bytes, non-<code>null</code>.
|
||||
* @throws IllegalArgumentException when string contains non-hex character
|
||||
*/
|
||||
public static byte[] hex2bin(final String s) {
|
||||
String m = s;
|
||||
@@ -85,10 +88,10 @@ public class BinTools {
|
||||
/**
|
||||
* Convert hex digit to numerical value.
|
||||
*
|
||||
* @param c 0-9, a-f, A-F allowd.
|
||||
* @param c 0-9, a-f, A-F allowed.
|
||||
*
|
||||
* @return 0-15 * @throws IllegalArgumentException
|
||||
* on non-hex character
|
||||
* @return 0-15
|
||||
* @throws IllegalArgumentException on non-hex character
|
||||
*/
|
||||
public static int hex2bin(char c) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
@@ -103,12 +106,8 @@ public class BinTools {
|
||||
throw new IllegalArgumentException("Input string may only contain hex digits, but found '" + c + "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method main.
|
||||
*
|
||||
* @param args String[]
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// TODO ljacqu 20151219: Move to a BinToolsTest class
|
||||
private static void testUtils(String[] args) {
|
||||
byte b[] = new byte[256];
|
||||
byte bb = 0;
|
||||
for (int i = 0; i < 256; i++) {
|
||||
|
||||
@@ -63,12 +63,6 @@ public class MacBasedPRF implements PRF {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for MacBasedPRF.
|
||||
*
|
||||
* @param macAlgorithm String
|
||||
* @param provider String
|
||||
*/
|
||||
public MacBasedPRF(String macAlgorithm, String provider) {
|
||||
this.macAlgorithm = macAlgorithm;
|
||||
try {
|
||||
@@ -79,34 +73,18 @@ public class MacBasedPRF implements PRF {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method doFinal.
|
||||
*
|
||||
* @param M byte[]
|
||||
*
|
||||
* @return byte[] * @see fr.xephi.authme.security.pbkdf2.PRF#doFinal(byte[])
|
||||
*/
|
||||
@Override
|
||||
public byte[] doFinal(byte[] M) {
|
||||
byte[] r = mac.doFinal(M);
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getHLen.
|
||||
*
|
||||
* @return int * @see fr.xephi.authme.security.pbkdf2.PRF#getHLen()
|
||||
*/
|
||||
@Override
|
||||
public int getHLen() {
|
||||
return hLen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method init.
|
||||
*
|
||||
* @param P byte[]
|
||||
*
|
||||
* @see fr.xephi.authme.security.pbkdf2.PRF#init(byte[])
|
||||
*/
|
||||
@Override
|
||||
public void init(byte[] P) {
|
||||
try {
|
||||
mac.init(new SecretKeySpec(P, macAlgorithm));
|
||||
|
||||
@@ -159,28 +159,15 @@ public class PBKDF2Engine implements PBKDF2 {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method deriveKey.
|
||||
*
|
||||
* @param inputPassword String
|
||||
*
|
||||
* @return byte[] * @see fr.xephi.authme.security.pbkdf2.PBKDF2#deriveKey(String)
|
||||
*/
|
||||
@Override
|
||||
public byte[] deriveKey(String inputPassword) {
|
||||
return deriveKey(inputPassword, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method deriveKey.
|
||||
*
|
||||
* @param inputPassword String
|
||||
* @param dkLen int
|
||||
*
|
||||
* @return byte[] * @see fr.xephi.authme.security.pbkdf2.PBKDF2#deriveKey(String, int)
|
||||
*/
|
||||
@Override
|
||||
public byte[] deriveKey(String inputPassword, int dkLen) {
|
||||
byte[] r = null;
|
||||
byte P[] = null;
|
||||
byte[] P = null;
|
||||
String charset = parameters.getHashCharset();
|
||||
if (inputPassword == null) {
|
||||
inputPassword = "";
|
||||
@@ -202,13 +189,7 @@ public class PBKDF2Engine implements PBKDF2 {
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method verifyKey.
|
||||
*
|
||||
* @param inputPassword String
|
||||
*
|
||||
* @return boolean * @see fr.xephi.authme.security.pbkdf2.PBKDF2#verifyKey(String)
|
||||
*/
|
||||
@Override
|
||||
public boolean verifyKey(String inputPassword) {
|
||||
byte[] referenceKey = getParameters().getDerivedKey();
|
||||
if (referenceKey == null || referenceKey.length == 0) {
|
||||
@@ -240,22 +221,12 @@ public class PBKDF2Engine implements PBKDF2 {
|
||||
prf.init(P);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getPseudoRandomFunction.
|
||||
*
|
||||
* @return PRF * @see fr.xephi.authme.security.pbkdf2.PBKDF2#getPseudoRandomFunction()
|
||||
*/
|
||||
@Override
|
||||
public PRF getPseudoRandomFunction() {
|
||||
return prf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setPseudoRandomFunction.
|
||||
*
|
||||
* @param prf PRF
|
||||
*
|
||||
* @see fr.xephi.authme.security.pbkdf2.PBKDF2#setPseudoRandomFunction(PRF)
|
||||
*/
|
||||
@Override
|
||||
public void setPseudoRandomFunction(PRF prf) {
|
||||
this.prf = prf;
|
||||
}
|
||||
@@ -369,22 +340,12 @@ public class PBKDF2Engine implements PBKDF2 {
|
||||
dest[offset + 3] = (byte) (i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getParameters.
|
||||
*
|
||||
* @return PBKDF2Parameters * @see fr.xephi.authme.security.pbkdf2.PBKDF2#getParameters()
|
||||
*/
|
||||
@Override
|
||||
public PBKDF2Parameters getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setParameters.
|
||||
*
|
||||
* @param parameters PBKDF2Parameters
|
||||
*
|
||||
* @see fr.xephi.authme.security.pbkdf2.PBKDF2#setParameters(PBKDF2Parameters)
|
||||
*/
|
||||
@Override
|
||||
public void setParameters(PBKDF2Parameters parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
@@ -33,14 +33,7 @@ package fr.xephi.authme.security.pbkdf2;
|
||||
*/
|
||||
public class PBKDF2HexFormatter implements PBKDF2Formatter {
|
||||
|
||||
/**
|
||||
* Method fromString.
|
||||
*
|
||||
* @param p PBKDF2Parameters
|
||||
* @param s String
|
||||
*
|
||||
* @return boolean * @see fr.xephi.authme.security.pbkdf2.PBKDF2Formatter#fromString(PBKDF2Parameters, String)
|
||||
*/
|
||||
@Override
|
||||
public boolean fromString(PBKDF2Parameters p, String s) {
|
||||
if (p == null || s == null) {
|
||||
return true;
|
||||
@@ -61,13 +54,7 @@ public class PBKDF2HexFormatter implements PBKDF2Formatter {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method toString.
|
||||
*
|
||||
* @param p PBKDF2Parameters
|
||||
*
|
||||
* @return String * @see fr.xephi.authme.security.pbkdf2.PBKDF2Formatter#toString(PBKDF2Parameters)
|
||||
*/
|
||||
@Override
|
||||
public String toString(PBKDF2Parameters p) {
|
||||
String s = BinTools.bin2hex(p.getSalt()) + ":" + String.valueOf(p.getIterationCount()) + ":" + BinTools.bin2hex(p.getDerivedKey());
|
||||
return s;
|
||||
|
||||
@@ -99,92 +99,42 @@ public class PBKDF2Parameters {
|
||||
this.derivedKey = derivedKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getIterationCount.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int getIterationCount() {
|
||||
return iterationCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setIterationCount.
|
||||
*
|
||||
* @param iterationCount int
|
||||
*/
|
||||
public void setIterationCount(int iterationCount) {
|
||||
this.iterationCount = iterationCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getSalt.
|
||||
*
|
||||
* @return byte[]
|
||||
*/
|
||||
public byte[] getSalt() {
|
||||
return salt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setSalt.
|
||||
*
|
||||
* @param salt byte[]
|
||||
*/
|
||||
public void setSalt(byte[] salt) {
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getDerivedKey.
|
||||
*
|
||||
* @return byte[]
|
||||
*/
|
||||
public byte[] getDerivedKey() {
|
||||
return derivedKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setDerivedKey.
|
||||
*
|
||||
* @param derivedKey byte[]
|
||||
*/
|
||||
public void setDerivedKey(byte[] derivedKey) {
|
||||
this.derivedKey = derivedKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getHashAlgorithm.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getHashAlgorithm() {
|
||||
return hashAlgorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setHashAlgorithm.
|
||||
*
|
||||
* @param hashAlgorithm String
|
||||
*/
|
||||
public void setHashAlgorithm(String hashAlgorithm) {
|
||||
this.hashAlgorithm = hashAlgorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getHashCharset.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getHashCharset() {
|
||||
return hashCharset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setHashCharset.
|
||||
*
|
||||
* @param hashCharset String
|
||||
*/
|
||||
public void setHashCharset(String hashCharset) {
|
||||
this.hashCharset = hashCharset;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user