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); }
public static String formulateJsonForListQueriesCall(Region<String, String> queryRegion) { HeapDataOutputStream outputStream = new HeapDataOutputStream(com.gemstone.gemfire.internal.Version.CURRENT); try { JsonGenerator generator = enableDisableJSONGeneratorFeature( getObjectMapper().getFactory().createGenerator(outputStream, JsonEncoding.UTF8)); JsonWriter.writeQueryListAsJson(generator, "queries", queryRegion); generator.close(); return new String(outputStream.toByteArray()); } catch (IOException e) { throw new RuntimeException(e.getMessage()); } finally { outputStream.close(); } }
public static String convertStructToJson(StructImpl structSet) throws JSONException { HeapDataOutputStream outputStream = new HeapDataOutputStream(com.gemstone.gemfire.internal.Version.CURRENT); try { JsonGenerator generator = enableDisableJSONGeneratorFeature( getObjectMapper().getFactory().createGenerator(outputStream, JsonEncoding.UTF8)); JsonWriter.writeStructAsJson(generator, structSet); generator.close(); return new String(outputStream.toByteArray()); } catch (IOException e) { throw new RuntimeException(e.getMessage()); } finally { outputStream.close(); } }
public static String formulateJsonForGetOnKey(Object value) throws JSONException { HeapDataOutputStream outputStream = new HeapDataOutputStream(com.gemstone.gemfire.internal.Version.CURRENT); try { JsonGenerator generator = enableDisableJSONGeneratorFeature( getObjectMapper().getFactory().createGenerator(outputStream, JsonEncoding.UTF8)); JsonWriter.writeValueAsJson(generator, value, "GET_ON_KEY_RESPONSE"); generator.close(); return new String(outputStream.toByteArray()); } catch (IOException e) { throw new RuntimeException(e.getMessage()); } finally { outputStream.close(); } }
public static String formulateJsonForListFunctionsCall(Set<String> functionIds) { HeapDataOutputStream outputStream = new HeapDataOutputStream(com.gemstone.gemfire.internal.Version.CURRENT); try { JsonGenerator generator = enableDisableJSONGeneratorFeature( getObjectMapper().getFactory().createGenerator(outputStream, JsonEncoding.UTF8)); generator.writeStartObject(); generator.writeFieldName("functions"); JsonWriter.writeCollectionAsJson(generator, functionIds); generator.writeEndObject(); generator.close(); return new String(outputStream.toByteArray()); } catch (IOException e) { throw new RuntimeException(e.getMessage()); } finally { outputStream.close(); } }
public static String formulateJsonForGetOnMultipleKey( Collection<Object> collection, String regionName) throws JSONException { HeapDataOutputStream outputStream = new HeapDataOutputStream(com.gemstone.gemfire.internal.Version.CURRENT); try { JsonGenerator generator = enableDisableJSONGeneratorFeature( getObjectMapper().getFactory().createGenerator(outputStream, JsonEncoding.UTF8)); generator.writeStartObject(); generator.writeFieldName(regionName); JsonWriter.writeCollectionAsJson(generator, collection); generator.writeEndObject(); generator.close(); return new String(outputStream.toByteArray()); } catch (IOException e) { throw new RuntimeException(e.getMessage()); } finally { outputStream.close(); } }