use of com.unboundid.ldap.sdk.IntermediateResponse in project ldapsdk by pingidentity.
the class ControlBasedOperationInterceptor method processAddResult.
/**
* {@inheritDoc}
*/
@Override()
public void processAddResult(final InMemoryInterceptedAddResult result) {
// See if there are any transformations that should be applied.
final Object transformTypesObj = result.getProperty(STATE_KEY_TRANSFORM_TYPES);
if (transformTypesObj == null) {
return;
}
@SuppressWarnings("unchecked") final Set<TransformType> transformTypes = (Set<TransformType>) transformTypesObj;
if (transformTypes.contains(TransformType.INJECT_INTERMEDIATE_RESPONSE)) {
try {
result.sendIntermediateResponse(new IntermediateResponse(INTERMEDIATE_RESPONSE_OID, new ASN1OctetString("Injected in Response")));
} catch (final Exception e) {
}
}
if (transformTypes.contains(TransformType.INJECT_UNSOLICITED_NOTIFICATION)) {
try {
result.sendUnsolicitedNotification(new ExtendedResult(0, ResultCode.SUCCESS, "Injected by Result", null, null, UNSOLICITED_NOTIFICATION_OID, null, null));
} catch (final Exception e) {
}
}
if (transformTypes.contains(TransformType.ERROR_RESULT)) {
result.setResult(new LDAPResult(result.getMessageID(), ResultCode.UNWILLING_TO_PERFORM, "Error result by transformation", null, StaticUtils.NO_STRINGS, StaticUtils.NO_CONTROLS));
}
if (transformTypes.contains(TransformType.RESULT_RUNTIME_EXCEPTION)) {
throw new RuntimeException();
}
}
use of com.unboundid.ldap.sdk.IntermediateResponse in project ldapsdk by pingidentity.
the class ControlBasedOperationInterceptor method processDeleteResult.
/**
* {@inheritDoc}
*/
@Override()
public void processDeleteResult(final InMemoryInterceptedDeleteResult result) {
// See if there are any transformations that should be applied.
final Object transformTypesObj = result.getProperty(STATE_KEY_TRANSFORM_TYPES);
if (transformTypesObj == null) {
return;
}
@SuppressWarnings("unchecked") final Set<TransformType> transformTypes = (Set<TransformType>) transformTypesObj;
if (transformTypes.contains(TransformType.INJECT_INTERMEDIATE_RESPONSE)) {
try {
result.sendIntermediateResponse(new IntermediateResponse(INTERMEDIATE_RESPONSE_OID, new ASN1OctetString("Injected in Response")));
} catch (final Exception e) {
}
}
if (transformTypes.contains(TransformType.INJECT_UNSOLICITED_NOTIFICATION)) {
try {
result.sendUnsolicitedNotification(new ExtendedResult(0, ResultCode.SUCCESS, "Injected by Result", null, null, UNSOLICITED_NOTIFICATION_OID, null, null));
} catch (final Exception e) {
}
}
if (transformTypes.contains(TransformType.ERROR_RESULT)) {
result.setResult(new LDAPResult(result.getMessageID(), ResultCode.UNWILLING_TO_PERFORM, "Error result by transformation", null, StaticUtils.NO_STRINGS, StaticUtils.NO_CONTROLS));
}
if (transformTypes.contains(TransformType.RESULT_RUNTIME_EXCEPTION)) {
throw new RuntimeException();
}
}
use of com.unboundid.ldap.sdk.IntermediateResponse in project ldapsdk by pingidentity.
the class ControlBasedOperationInterceptor method processSearchResult.
/**
* {@inheritDoc}
*/
@Override()
public void processSearchResult(final InMemoryInterceptedSearchResult result) {
// See if there are any transformations that should be applied.
final Object transformTypesObj = result.getProperty(STATE_KEY_TRANSFORM_TYPES);
if (transformTypesObj == null) {
return;
}
@SuppressWarnings("unchecked") final Set<TransformType> transformTypes = (Set<TransformType>) transformTypesObj;
if (transformTypes.contains(TransformType.INJECT_ENTRY)) {
try {
result.sendSearchEntry(new Entry("dn: ou=Result,ou=injected,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: Result"));
} catch (final Exception e) {
}
}
if (transformTypes.contains(TransformType.INJECT_REFERENCE)) {
try {
final String[] referralURLs = { "ldap://" + result.getConnectedAddress() + ':' + result.getConnectedPort() + "/ou=Result,ou=injected,dc=example,dc=com" };
result.sendSearchReference(new SearchResultReference(referralURLs, null));
} catch (final Exception e) {
}
}
if (transformTypes.contains(TransformType.INJECT_INTERMEDIATE_RESPONSE)) {
try {
result.sendIntermediateResponse(new IntermediateResponse(INTERMEDIATE_RESPONSE_OID, new ASN1OctetString("Injected in Response")));
} catch (final Exception e) {
}
}
if (transformTypes.contains(TransformType.INJECT_UNSOLICITED_NOTIFICATION)) {
try {
result.sendUnsolicitedNotification(new ExtendedResult(0, ResultCode.SUCCESS, "Injected by Result", null, null, UNSOLICITED_NOTIFICATION_OID, null, null));
} catch (final Exception e) {
}
}
if (transformTypes.contains(TransformType.ERROR_RESULT)) {
result.setResult(new LDAPResult(result.getMessageID(), ResultCode.UNWILLING_TO_PERFORM, "Error result by transformation", null, StaticUtils.NO_STRINGS, StaticUtils.NO_CONTROLS));
}
if (transformTypes.contains(TransformType.RESULT_RUNTIME_EXCEPTION)) {
throw new RuntimeException();
}
}
use of com.unboundid.ldap.sdk.IntermediateResponse in project ldapsdk by pingidentity.
the class ControlBasedOperationInterceptor method processSimpleBindResult.
/**
* {@inheritDoc}
*/
@Override()
public void processSimpleBindResult(final InMemoryInterceptedSimpleBindResult result) {
// See if there are any transformations that should be applied.
final Object transformTypesObj = result.getProperty(STATE_KEY_TRANSFORM_TYPES);
if (transformTypesObj == null) {
return;
}
@SuppressWarnings("unchecked") final Set<TransformType> transformTypes = (Set<TransformType>) transformTypesObj;
if (transformTypes.contains(TransformType.INJECT_INTERMEDIATE_RESPONSE)) {
try {
result.sendIntermediateResponse(new IntermediateResponse(INTERMEDIATE_RESPONSE_OID, new ASN1OctetString("Injected in Response")));
} catch (final Exception e) {
}
}
if (transformTypes.contains(TransformType.INJECT_UNSOLICITED_NOTIFICATION)) {
try {
result.sendUnsolicitedNotification(new ExtendedResult(0, ResultCode.SUCCESS, "Injected by Result", null, null, UNSOLICITED_NOTIFICATION_OID, null, null));
} catch (final Exception e) {
}
}
if (transformTypes.contains(TransformType.ERROR_RESULT)) {
result.setResult(new BindResult(result.getMessageID(), ResultCode.UNWILLING_TO_PERFORM, "Error result by transformation", null, StaticUtils.NO_STRINGS, StaticUtils.NO_CONTROLS, null));
}
if (transformTypes.contains(TransformType.RESULT_RUNTIME_EXCEPTION)) {
throw new RuntimeException();
}
}
use of com.unboundid.ldap.sdk.IntermediateResponse in project ldapsdk by pingidentity.
the class ControlBasedOperationInterceptor method processSASLBindResult.
/**
* {@inheritDoc}
*/
@Override()
public void processSASLBindResult(final InMemoryInterceptedSASLBindResult result) {
// See if there are any transformations that should be applied.
final Object transformTypesObj = result.getProperty(STATE_KEY_TRANSFORM_TYPES);
if (transformTypesObj == null) {
return;
}
@SuppressWarnings("unchecked") final Set<TransformType> transformTypes = (Set<TransformType>) transformTypesObj;
if (transformTypes.contains(TransformType.INJECT_INTERMEDIATE_RESPONSE)) {
try {
result.sendIntermediateResponse(new IntermediateResponse(INTERMEDIATE_RESPONSE_OID, new ASN1OctetString("Injected in Response")));
} catch (final Exception e) {
}
}
if (transformTypes.contains(TransformType.INJECT_UNSOLICITED_NOTIFICATION)) {
try {
result.sendUnsolicitedNotification(new ExtendedResult(0, ResultCode.SUCCESS, "Injected by Result", null, null, UNSOLICITED_NOTIFICATION_OID, null, null));
} catch (final Exception e) {
}
}
if (transformTypes.contains(TransformType.ERROR_RESULT)) {
result.setResult(new BindResult(result.getMessageID(), ResultCode.UNWILLING_TO_PERFORM, "Error result by transformation", null, StaticUtils.NO_STRINGS, StaticUtils.NO_CONTROLS, null));
}
if (transformTypes.contains(TransformType.RESULT_RUNTIME_EXCEPTION)) {
throw new RuntimeException();
}
}
Aggregations