コード例 #1
0
 protected Object processResponse(Connection cnx, Message msg) throws Exception {
   byte[] bytes = null;
   Part part = msg.getPart(0);
   final int msgType = msg.getMessageType();
   long userId = -1;
   if (msgType == MessageType.RESPONSE) {
     bytes = (byte[]) part.getObject();
     if (bytes.length == 0) {
       cnx.getServer().setRequiresCredentials(false);
     } else {
       cnx.getServer().setRequiresCredentials(true);
       byte[] decrypted = ((ConnectionImpl) cnx).getHandShake().decryptBytes(bytes);
       DataInputStream dis = new DataInputStream(new ByteArrayInputStream(decrypted));
       userId = dis.readLong();
     }
     if (this.needsServerLocation) {
       return new Object[] {cnx.getServer(), userId};
     } else {
       return userId;
     }
   } else if (msgType == MessageType.EXCEPTION) {
     Object result = part.getObject();
     String s = "While performing a remote authenticate";
     if (result instanceof AuthenticationFailedException) {
       final AuthenticationFailedException afe = (AuthenticationFailedException) result;
       if ("REPLY_REFUSED".equals(afe.getMessage())) {
         throw new AuthenticationFailedException(s, afe.getCause());
       } else {
         throw new AuthenticationFailedException(s, afe);
       }
     } else if (result instanceof AuthenticationRequiredException) {
       throw new AuthenticationRequiredException(s, (AuthenticationRequiredException) result);
     } else if (result instanceof NotAuthorizedException) {
       throw new NotAuthorizedException(s, (NotAuthorizedException) result);
     } else {
       throw new ServerOperationException(s, (Throwable) result);
     }
     // Get the exception toString part.
     // This was added for c++ thin client and not used in java
     // Part exceptionToStringPart = msg.getPart(1);
   } else if (isErrorResponse(msgType)) {
     throw new ServerOperationException(part.getString());
   } else {
     throw new InternalGemFireError("Unexpected message type " + MessageType.getString(msgType));
   }
 }
コード例 #2
0
 @Override
 public Object attempt(Connection cnx) throws Exception {
   if (cnx.getServer().getRequiresCredentials()) {
     return super.attempt(cnx);
   } else {
     return null;
   }
 }