diff --git a/.classpath b/.classpath index 907ff21..88d37ef 100644 --- a/.classpath +++ b/.classpath @@ -24,5 +24,10 @@ + + + + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 8bc0e1c..04cfa2c 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,5 +1,6 @@ eclipse.preferences.version=1 encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 encoding//src/test/java=UTF-8 encoding//src/test/resources=UTF-8 encoding/=UTF-8 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 44f2db9..08f7658 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,17 +1,22 @@ - + + - + + - + + + - + + diff --git a/src/main/java/envoy/data/LoginCredentials.java b/src/main/java/envoy/data/LoginCredentials.java index 58d14d4..9b29c07 100644 --- a/src/main/java/envoy/data/LoginCredentials.java +++ b/src/main/java/envoy/data/LoginCredentials.java @@ -19,20 +19,24 @@ public class LoginCredentials implements Serializable { private final String name; private final byte[] passwordHash; + private final boolean registration; private static final long serialVersionUID = -7395245059059523314L; /** * Creates an in stance of {@link LoginCredentials}. * - * @param name the name of the user - * @param password the password of the user (will be converted to a hash) + * @param name the name of the user + * @param password the password of the user (will be converted to a hash) + * @param registration signifies that these credentials are used for user + * registration instead of user login * @throws NoSuchAlgorithmException if the algorithm used is unknown * @since Envoy Common v0.2-alpha */ - public LoginCredentials(String name, char[] password) throws NoSuchAlgorithmException { - this.name = name; - passwordHash = getSha256(toByteArray(password)); + public LoginCredentials(String name, char[] password, boolean registration) throws NoSuchAlgorithmException { + this.name = name; + passwordHash = getSha256(toByteArray(password)); + this.registration = registration; } private byte[] getSha256(byte[] input) throws NoSuchAlgorithmException { return MessageDigest.getInstance("SHA-256").digest(input); } @@ -52,7 +56,7 @@ public class LoginCredentials implements Serializable { form.format("LoginCredentials[name=%s,passwordHash=", name); for (byte element : passwordHash) form.format("%02x", element); - return form.format("]").toString(); + return form.format(",registration=%b]", registration).toString(); } } @@ -67,4 +71,11 @@ public class LoginCredentials implements Serializable { * @since Envoy Common v0.2-alpha */ public byte[] getPasswordHash() { return passwordHash; } + + /** + * @return {@code true} if these credentials are used for user registration + * instead of user login + * @since Envoy Common v0.2-alpha + */ + public boolean isRegistration() { return registration; } } \ No newline at end of file