Removed checked exception from LoginCredential constructor

This commit is contained in:
Kai S. K. Engelbart 2020-04-10 13:43:53 +02:00
parent cb727ca084
commit 7342841b33
4 changed files with 39 additions and 28 deletions

View File

@ -21,7 +21,6 @@
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>

View File

@ -1,22 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="envoy-common">
<wb-resource deploy-path="/" source-path="/src/main/java"/>
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
</wb-module>
</project-modules>
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="envoy-common">
<wb-resource deploy-path="/" source-path="/src/main/java"/>
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
</wb-module>
</project-modules>

View File

@ -27,11 +27,12 @@ public final class GroupMessage extends Message {
*
* @param id unique ID
* @param senderID the ID of the user who sends the message
* @param recipientID the ID of the user who receives the message
* @param groupID the ID of the group which receives the message
* @param creationDate the creation date of the message
* @param text the text content of the message
* @param attachment the attachment of the message, if present
* @param status the current {@link MessageStatus} of the message
* @param status the current {@link Message.MessageStatus} of the
* message
* @param forwarded whether this message was forwarded
* @param memberStatuses a map of all members and their status according to this
* {@link GroupMessage}

View File

@ -30,16 +30,22 @@ public class LoginCredentials implements Serializable {
* @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 identifier, char[] password, boolean registration) throws NoSuchAlgorithmException {
public LoginCredentials(String identifier, char[] password, boolean registration) {
this.identifier = identifier;
passwordHash = getSha256(toByteArray(password));
this.registration = registration;
}
private byte[] getSha256(byte[] input) throws NoSuchAlgorithmException { return MessageDigest.getInstance("SHA-256").digest(input); }
private byte[] getSha256(byte[] input) {
try {
return MessageDigest.getInstance("SHA-256").digest(input);
} catch (NoSuchAlgorithmException e) {
// This will never happen
throw new RuntimeException(e);
}
}
private byte[] toByteArray(char[] chars) {
byte[] bytes = new byte[chars.length * 2];