use of org.apache.geode.security.AuthenticationRequiredException in project geode by apache.
the class HandShake method handshakeWithSubscriptionFeed.
/**
* Used by client-side CacheClientUpdater to handshake with a server in order to receive messages
* generated by subscriptions (register-interest, continuous query)
*/
public ServerQueueStatus handshakeWithSubscriptionFeed(Socket sock, boolean isPrimary) throws IOException, AuthenticationRequiredException, AuthenticationFailedException, ServerRefusedConnectionException, ClassNotFoundException {
ServerQueueStatus sqs = null;
try {
DataOutputStream dos = new DataOutputStream(sock.getOutputStream());
final InputStream in = sock.getInputStream();
DataInputStream dis = new DataInputStream(in);
DistributedMember member = getIDForSocket(sock);
if (!this.multiuserSecureMode) {
this.credentials = getCredentials(member);
}
byte mode = isPrimary ? Acceptor.PRIMARY_SERVER_TO_CLIENT : Acceptor.SECONDARY_SERVER_TO_CLIENT;
write(dos, dis, mode, REPLY_OK, 0, new ArrayList(), this.credentials, member, true);
// Wait here for a reply before continuing. This ensures that the client
// updater is registered with the server before continuing.
byte acceptanceCode = dis.readByte();
if (acceptanceCode == (byte) 21 && !(sock instanceof SSLSocket)) {
// SSL
throw new AuthenticationRequiredException(LocalizedStrings.HandShake_SERVER_EXPECTING_SSL_CONNECTION.toLocalizedString());
}
// No need to check for return value since DataInputStream already throws
// EOFException in case of EOF
byte qType = dis.readByte();
// read and ignore qSize flag
int qSize = dis.readInt();
sqs = new ServerQueueStatus(qType, qSize, member);
// Read the message (if any)
readMessage(dis, dos, acceptanceCode, member);
// clients but that is not used in tests
if (currentClientVersion.compareTo(Version.GFE_61) < 0) {
return sqs;
}
HashMap instantiatorMap = DataSerializer.readHashMap(dis);
for (Iterator itr = instantiatorMap.entrySet().iterator(); itr.hasNext(); ) {
Map.Entry instantiator = (Map.Entry) itr.next();
Integer id = (Integer) instantiator.getKey();
ArrayList instantiatorArguments = (ArrayList) instantiator.getValue();
InternalInstantiator.register((String) instantiatorArguments.get(0), (String) instantiatorArguments.get(1), id, false);
}
HashMap dataSerializersMap = DataSerializer.readHashMap(dis);
for (Iterator itr = dataSerializersMap.entrySet().iterator(); itr.hasNext(); ) {
Map.Entry dataSerializer = (Map.Entry) itr.next();
Integer id = (Integer) dataSerializer.getKey();
InternalDataSerializer.register((String) dataSerializer.getValue(), false, null, null, id);
}
HashMap<Integer, ArrayList<String>> dsToSupportedClassNames = DataSerializer.readHashMap(dis);
InternalDataSerializer.updateSupportedClassesMap(dsToSupportedClassNames);
} catch (IOException ex) {
CancelCriterion stopper = this.system.getCancelCriterion();
stopper.checkCancelInProgress(null);
throw ex;
} catch (ClassNotFoundException ex) {
CancelCriterion stopper = this.system.getCancelCriterion();
stopper.checkCancelInProgress(null);
throw ex;
}
return sqs;
}
use of org.apache.geode.security.AuthenticationRequiredException in project geode by apache.
the class MessageIdExtractor method getAuthIdsFromMessage.
private AuthIds getAuthIdsFromMessage(Message requestMessage, HandShake handshake) throws AuthenticationRequiredException {
try {
byte[] secureBytes = requestMessage.getSecureBytes();
secureBytes = handshake.decryptBytes(secureBytes);
return new AuthIds(secureBytes);
} catch (Exception ex) {
throw new AuthenticationRequiredException(LocalizedStrings.HandShake_NO_SECURITY_CREDENTIALS_ARE_PROVIDED.toLocalizedString(), ex);
}
}
Aggregations