diff options
| author | Nils Schwabe | 2014-05-07 15:23:26 +0200 |
|---|---|---|
| committer | Nils Schwabe | 2014-05-07 15:23:26 +0200 |
| commit | b02181e54011a01df82e4450ae884ebca920a300 (patch) | |
| tree | 4ed9deb319f6ab2bacaac4cf7333919320949e2c /src/main/java/org/openslx/imagemaster/util | |
| parent | Fix message signing (diff) | |
| download | masterserver-b02181e54011a01df82e4450ae884ebca920a300.tar.gz masterserver-b02181e54011a01df82e4450ae884ebca920a300.tar.xz masterserver-b02181e54011a01df82e4450ae884ebca920a300.zip | |
Fix bug where the user list was accessed by multiple threads
Add server keys to database
Diffstat (limited to 'src/main/java/org/openslx/imagemaster/util')
| -rw-r--r-- | src/main/java/org/openslx/imagemaster/util/AsymMessageSign.java | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/src/main/java/org/openslx/imagemaster/util/AsymMessageSign.java b/src/main/java/org/openslx/imagemaster/util/AsymMessageSign.java deleted file mode 100644 index c49f9db..0000000 --- a/src/main/java/org/openslx/imagemaster/util/AsymMessageSign.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.openslx.imagemaster.util; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.security.InvalidKeyException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.PublicKey; -import java.security.Signature; -import java.security.SignatureException; -import java.security.UnrecoverableKeyException; -import java.security.cert.CertificateException; - -public class AsymMessageSign -{ - - private KeyStore keystore; - - /** - * Load the keystore - * @param file Path to keystore - * @param password The keystore's password - * @throws NoSuchAlgorithmException - * @throws CertificateException - * @throws FileNotFoundException - * @throws IOException - * @throws KeyStoreException - * @throws UnrecoverableKeyException - */ - public AsymMessageSign(String file, String password) throws NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException, KeyStoreException, UnrecoverableKeyException - { - keystore = KeyStore.getInstance( "JKS" ); - keystore.load( new FileInputStream( new File( file ) ), password.toCharArray() ); - } - - /** - * Verify an encrypted message - * @param signedMessage The signed message from hs/uni server - * @param realMessage The message that was sent before - * @param alias the alias of the certificate - * @param password the password of the certificate - * @return Whether the message could be verfied or not - * @throws NoSuchAlgorithmException - * @throws InvalidKeyException - * @throws SignatureException - * @throws UnrecoverableKeyException - * @throws KeyStoreException - */ - public boolean verifyMessage( byte[] signedMessage, byte[] realMessage, String alias ) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException, UnrecoverableKeyException, KeyStoreException - { - // first load key - //Key key = keystore.getKey( alias, password.toCharArray() ); - PublicKey key = keystore.getCertificate( alias ).getPublicKey(); - - // verify message - Signature signature = Signature.getInstance( "SHA256WITHRSA" ); - signature.initVerify( key ); - signature.update( realMessage ); - return signature.verify( signedMessage ); - } - -} |
