1 package org.openslx.imagemaster.serversession;
3 import java.nio.ByteBuffer;
5 import java.util.concurrent.ConcurrentHashMap;
7 import org.apache.logging.log4j.LogManager;
8 import org.apache.logging.log4j.Logger;
9 import org.apache.thrift.TException;
10 import org.
openslx.bwlp.thrift.iface.AuthorizationError;
11 import org.
openslx.bwlp.thrift.iface.TAuthorizationException;
12 import org.
openslx.encryption.AsymEncryptionHandler;
39 authenticatingServers.put( satelliteId, secret );
40 log.info(
"Server of organinzation '" + satelliteId
41 +
"' starts to authenticate. And got string: '" + secret.length
43 return ByteBuffer.wrap( secret );
56 throws TAuthorizationException
58 byte[] encryptedBytes =
new byte[ challengeResponse.remaining() ];
59 challengeResponse.get( encryptedBytes );
61 AsymEncryptionHandler verifier =
new AsymEncryptionHandler( satellite.getPubkey() );
63 if ( !verifier.verifyMessage( encryptedBytes, authenticatingServers.get( satellite.satelliteId ) ) ) {
64 throw new TAuthorizationException( AuthorizationError.CHALLENGE_FAILED,
65 "You failed the encryption challenge. private and public key don't seem to match." );
68 log.info(
"Server '" + satellite.satelliteName +
"' (" + satellite.organizationId +
") authenticated." );
70 authenticatingServers.remove( Integer.valueOf( satellite.organizationId ) );
static ByteBuffer startServerAuthentication(int satelliteId)
Start the server authentification.
Generate secure random strings.
Authenticating a server with message signing.
static Map< Integer, byte[]> authenticatingServers
Servers currently doing authentication.
static void serverAuthenticate(LocalSatellite satellite, ByteBuffer challengeResponse)
Authenticate with the challengeResponse.
static byte[] generateBinary(int length)
Generate random binary data.