heapdos.close(); getMessage().addBytesPart(credentialBytes); hdos.close(); getMessage().setSecurePart(secureBytes); getMessage().send(false);
} else if (isErrorResponse(msgType)) { throw new ServerOperationException(part.getString()); } else {
public AuthenticateUserOpImpl(Connection con, ExecutablePool pool) { super(MessageType.USER_CREDENTIAL_MESSAGE, 1); byte[] credentialBytes = null; DistributedMember server = new InternalDistributedMember(con.getSocket().getInetAddress(), con.getSocket().getPort(), false); DistributedSystem sys = InternalDistributedSystem.getConnectedInstance(); String authInitMethod = sys.getProperties().getProperty(SECURITY_CLIENT_AUTH_INIT); Properties tmpSecurityProperties = sys.getSecurityProperties(); // LOG: following passes the DS API LogWriters into the security API Properties credentials = Handshake.getCredentials(authInitMethod, tmpSecurityProperties, server, false, (InternalLogWriter) sys.getLogWriter(), (InternalLogWriter) sys.getSecurityLogWriter()); getMessage().setMessageHasSecurePartFlag(); HeapDataOutputStream heapdos = new HeapDataOutputStream(Version.CURRENT); try { DataSerializer.writeProperties(credentials, heapdos); credentialBytes = ((ConnectionImpl) con).encryptBytes(heapdos.toByteArray()); } catch (Exception e) { throw new ServerOperationException(e); } finally { heapdos.close(); } getMessage().addBytesPart(credentialBytes); }
@Override protected Object attemptReadResponse(Connection cnx) throws Exception { Message msg = createResponseMessage(); if (msg != null) { msg.setComms(cnx.getSocket(), cnx.getInputStream(), cnx.getOutputStream(), cnx.getCommBuffer(), cnx.getStats()); if (msg instanceof ChunkedMessage) { try { return processResponse(cnx, msg); } finally { msg.unsetComms(); processSecureBytes(cnx, msg); } } else { try { msg.receive(); } finally { msg.unsetComms(); processSecureBytes(cnx, msg); } return processResponse(cnx, msg); } } else { return null; } }
/** * Sends the auth credentials to the server for a particular user. Used in multiple user mode of * authentication. * * @param location The ServerLocation instance whose connection instance will be used to perform * the operation. * @param pool The connection pool to use for this operation. * @return Object unique user-id. */ public static Object executeOn(ServerLocation location, ExecutablePool pool, Properties securityProps) { AbstractOp op = new AuthenticateUserOpImpl(pool, securityProps); return pool.executeOn(location, op); }
@Override protected void endSendAttempt(ConnectionStats stats, long start) { stats.endGetSend(start, hasFailed()); }
public AuthenticateUserOpImpl(ExecutablePool pool, Properties securityProps, boolean needsServer) { super(MessageType.USER_CREDENTIAL_MESSAGE, 1); this.securityProperties = securityProps; this.needsServerLocation = needsServer; getMessage().setMessageHasSecurePartFlag(); }
@Override protected void endAttempt(ConnectionStats stats, long start) { stats.endGet(start, hasTimedOut(), hasFailed()); }
/** * Sends the auth credentials to the server. Used in single user mode of authentication. * * @param con The connection to use for this operation. * @param pool The connection pool to use for this operation. * @return Object unique user-id. */ public static Object executeOn(Connection con, ExecutablePool pool) { AbstractOp op = new AuthenticateUserOpImpl(con, pool); return pool.executeOn(con, op); }