public AuthenticateUserOpImpl(Connection con, ExecutablePool pool) { super(MessageType.USER_CREDENTIAL_MESSAGE, 1); byte[] credentialBytes = null; // TODO this is not a valid way to create a member ID DistributedMember server = new InternalDistributedMember( con.getSocket().getInetAddress(), con.getSocket().getPort(), false); DistributedSystem sys = InternalDistributedSystem.getConnectedInstance(); String authInitMethod = sys.getProperties().getProperty(DistributionConfig.SECURITY_CLIENT_AUTH_INIT_NAME); 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().setEarlyAck(Message.MESSAGE_HAS_SECURE_PART); HeapDataOutputStream heapdos = new HeapDataOutputStream(Version.CURRENT); try { DataSerializer.writeProperties(credentials, heapdos); credentialBytes = ((ConnectionImpl) con).getHandShake().encryptBytes(heapdos.toByteArray()); } catch (Exception e) { throw new ServerOperationException(e); } finally { heapdos.close(); } getMessage().addBytesPart(credentialBytes); }
@Override protected void sendMessage(Connection cnx) throws Exception { HeapDataOutputStream hdos = new HeapDataOutputStream(Version.CURRENT); byte[] secureBytes = null; hdos.writeLong(cnx.getConnectionID()); if (this.securityProperties != null) { byte[] credentialBytes = null; // TODO this is not a valid way to create a member ID DistributedMember server = new InternalDistributedMember( cnx.getSocket().getInetAddress(), cnx.getSocket().getPort(), false); DistributedSystem sys = InternalDistributedSystem.getConnectedInstance(); String authInitMethod = sys.getProperties().getProperty(DistributionConfig.SECURITY_CLIENT_AUTH_INIT_NAME); Properties credentials = HandShake.getCredentials( authInitMethod, this.securityProperties, server, false, (InternalLogWriter) sys.getLogWriter(), (InternalLogWriter) sys.getSecurityLogWriter()); HeapDataOutputStream heapdos = new HeapDataOutputStream(Version.CURRENT); try { DataSerializer.writeProperties(credentials, heapdos); credentialBytes = ((ConnectionImpl) cnx).getHandShake().encryptBytes(heapdos.toByteArray()); } finally { heapdos.close(); } getMessage().addBytesPart(credentialBytes); } try { secureBytes = ((ConnectionImpl) cnx).getHandShake().encryptBytes(hdos.toByteArray()); } finally { hdos.close(); } getMessage().setSecurePart(secureBytes); getMessage().send(false); }