//Create a copy so we don't encrypt the existing reference
ConnectionCredentials copy = ConnectionCredentials.copyOf(connectionCredentials);
ConnectionCredentialsEncrypter credentialsEncrypter = new ConnectionCredentialsEncrypter();
credentialsEncrypter.encrypt(copy);
jgen.writeStartObject();
if (copy.getIdentity() != null) {
jgen.writeStringField("identity",copy.getIdentity());
}