use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class AbstractOp method sendMessage.
/**
* New implementations of AbstractOp should override this method if the implementation should be
* excluded from client authentication. e.g. PingOp#sendMessage(Connection cnx)
*
* @see AbstractOp#needsUserId()
* @see AbstractOp#processSecureBytes(Connection, Message)
* @see ServerConnection#updateAndGetSecurityPart()
*/
protected void sendMessage(Connection cnx) throws Exception {
if (cnx.getServer().getRequiresCredentials()) {
// Security is enabled on client as well as on server
getMessage().setMessageHasSecurePartFlag();
long userId = -1;
if (UserAttributes.userAttributes.get() == null) {
// single user mode
userId = cnx.getServer().getUserId();
} else {
// multi user mode
Object id = UserAttributes.userAttributes.get().getServerToId().get(cnx.getServer());
if (id == null) {
// the retryCount is exhausted. Fix for Bug 41501
throw new ServerConnectivityException("Connection error while authenticating user");
}
userId = (Long) id;
}
HeapDataOutputStream hdos = new HeapDataOutputStream(Version.CURRENT);
try {
hdos.writeLong(cnx.getConnectionID());
hdos.writeLong(userId);
getMessage().setSecurePart(((ConnectionImpl) cnx).getHandShake().encryptBytes(hdos.toByteArray()));
} finally {
hdos.close();
}
}
getMessage().send(false);
}
use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class EventID method initializeAndGetDSEventIdentity.
private static byte[] initializeAndGetDSEventIdentity(DistributedSystem sys) {
if (sys == null) {
// DistributedSystem is required now before handshaking -Kirk
throw new IllegalStateException(LocalizedStrings.ClientProxyMembershipID_ATTEMPTING_TO_HANDSHAKE_WITH_CACHESERVER_BEFORE_CREATING_DISTRIBUTEDSYSTEM_AND_CACHE.toLocalizedString());
}
if (EventID.system != sys) {
// DS already exists... make sure it's for current DS connection
EventID.systemMemberId = sys.getDistributedMember();
try {
HeapDataOutputStream hdos = new HeapDataOutputStream(256, Version.CURRENT);
((InternalDistributedMember) EventID.systemMemberId).writeEssentialData(hdos);
client_side_event_identity = hdos.toByteArray();
} catch (IOException ioe) {
throw new InternalGemFireException(LocalizedStrings.ClientProxyMembershipID_UNABLE_TO_SERIALIZE_IDENTITY.toLocalizedString(), ioe);
}
EventID.system = sys;
}
return EventID.client_side_event_identity;
}
use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class GraphReader method readGraphs.
public GraphSet readGraphs(Filter filter, boolean areGemfireLogs) throws IOException {
GraphSet graphs = new GraphSet();
if (areGemfireLogs) {
// TODO - probably don't need to go all the way
// to a binary format here, but this is quick and easy.
HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT);
GemfireLogConverter.convertFiles(out, files);
InputStreamReader reader = new InputStreamReader(out.getInputStream());
reader.addToGraphs(graphs, filter);
} else {
for (File file : files) {
FileInputStream fis = new FileInputStream(file);
InputStreamReader reader = new InputStreamReader(fis);
reader.addToGraphs(graphs, filter);
}
}
graphs.readingDone();
return graphs;
}
use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class PdxToJSON method getJSON.
public String getJSON() {
JsonFactory jf = new JsonFactory();
// OutputStream os = new ByteArrayOutputStream();
HeapDataOutputStream hdos = new HeapDataOutputStream(org.apache.geode.internal.Version.CURRENT);
try {
JsonGenerator jg = jf.createJsonGenerator(hdos, JsonEncoding.UTF8);
enableDisableJSONGeneratorFeature(jg);
getJSONString(jg, m_pdxInstance);
jg.close();
return new String(hdos.toByteArray());
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
} finally {
hdos.close();
}
}
use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class PdxToJSON method getJSONByteArray.
public byte[] getJSONByteArray() {
JsonFactory jf = new JsonFactory();
HeapDataOutputStream hdos = new HeapDataOutputStream(org.apache.geode.internal.Version.CURRENT);
try {
JsonGenerator jg = jf.createJsonGenerator(hdos, JsonEncoding.UTF8);
enableDisableJSONGeneratorFeature(jg);
getJSONString(jg, m_pdxInstance);
jg.close();
return hdos.toByteArray();
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
} finally {
hdos.close();
}
}
Aggregations