|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.unboundid.ldap.sdk.Control
com.unboundid.ldap.sdk.controls.AssertionRequestControl
@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class AssertionRequestControl
This class provides an implementation of the LDAP assertion request control
as defined in RFC 4528. It
may be used in conjunction with an add, compare, delete, modify, modify DN,
or search operation. The assertion control includes a search filter, and the
associated operation should only be allowed to continue if the target entry
matches the provided filter. If the filter does not match the target entry,
then the operation should fail with an
ResultCode.ASSERTION_FAILED
result.
The behavior of the assertion request control makes it ideal for atomic
"check and set" types of operations, particularly when modifying an entry.
For example, it can be used to ensure that when changing the value of an
attribute, the current value has not been modified since it was last
retrieved.
Modification mod = new Modification(ModificationType.REPLACE, "accountBalance", "543.21"); ModifyRequest modifyRequest = new ModifyRequest("uid=john.doe,ou=People,dc=example,dc=com", mod); modifyRequest.addControl( new AssertionRequestControl("(accountBalance=1234.56)")); LDAPResult modifyResult; try { modifyResult = connection.modify(modifyRequest); // If we've gotten here, then the modification was successful. } catch (LDAPException le) { modifyResult = le.toLDAPResult(); ResultCode resultCode = le.getResultCode(); String errorMessageFromServer = le.getDiagnosticMessage(); if (resultCode == ResultCode.ASSERTION_FAILED) { // The modification failed because the account balance value wasn't // what we thought it was. } else { // The modification failed for some other reason. } }
Field Summary | |
---|---|
static java.lang.String |
ASSERTION_REQUEST_OID
The OID (1.3.6.1.1.12) for the assertion request control. |
Constructor Summary | |
---|---|
AssertionRequestControl(Control control)
Creates a new assertion request control which is decoded from the provided generic control. |
|
AssertionRequestControl(Filter filter)
Creates a new assertion request control with the provided filter. |
|
AssertionRequestControl(Filter filter,
boolean isCritical)
Creates a new assertion request control with the provided filter. |
|
AssertionRequestControl(java.lang.String filter)
Creates a new assertion request control with the provided filter. |
|
AssertionRequestControl(java.lang.String filter,
boolean isCritical)
Creates a new assertion request control with the provided filter. |
Method Summary | |
---|---|
static AssertionRequestControl |
generate(Entry sourceEntry,
java.lang.String... attributes)
Generates an assertion request control that may be used to help ensure that some or all of the attributes in the specified entry have not changed since it was read from the server. |
java.lang.String |
getControlName()
Retrieves the user-friendly name for this control, if available. |
Filter |
getFilter()
Retrieves the filter for this assertion control. |
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this LDAP control to the provided buffer. |
Methods inherited from class com.unboundid.ldap.sdk.Control |
---|
decode, decode, decodeControls, deregisterDecodeableControl, encode, encodeControls, equals, getOID, getValue, hashCode, hasValue, isCritical, readFrom, registerDecodeableControl, toString, writeTo |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ASSERTION_REQUEST_OID
Constructor Detail |
---|
public AssertionRequestControl(java.lang.String filter) throws LDAPException
filter
- The string representation of the filter for this assertion
control. It must not be null
.
LDAPException
- If the provided filter string cannot be decoded as
a search filter.public AssertionRequestControl(Filter filter)
filter
- The filter for this assertion control. It must not be
null
.public AssertionRequestControl(java.lang.String filter, boolean isCritical) throws LDAPException
filter
- The string representation of the filter for this
assertion control. It must not be null
.isCritical
- Indicates whether this control should be marked
critical.
LDAPException
- If the provided filter string cannot be decoded as
a search filter.public AssertionRequestControl(Filter filter, boolean isCritical)
filter
- The filter for this assertion control. It must not be
null
.isCritical
- Indicates whether this control should be marked
critical.public AssertionRequestControl(Control control) throws LDAPException
control
- The generic control to be decoded as an assertion request
control.
LDAPException
- If the provided control cannot be decoded as an
assertion request control.Method Detail |
---|
public static AssertionRequestControl generate(Entry sourceEntry, java.lang.String... attributes)
sourceEntry
- The entry from which to take the attributes to include
in the assertion request control. It must not be
null
and should have at least one attribute to
be included in the generated filter.attributes
- The names of the attributes to include in the
assertion request control. If this is empty or
null
, then all attributes in the provided
entry will be used.
public Filter getFilter()
public java.lang.String getControlName()
getControlName
in class Control
public void toString(java.lang.StringBuilder buffer)
toString
in class Control
buffer
- The buffer to which to append the string representation of
this buffer.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |