@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class AssertionRequestControl extends Control
ResultCode.ASSERTION_FAILED
result.
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. } }
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ASSERTION_REQUEST_OID
The OID (1.3.6.1.1.12) for the assertion request control.
|
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
static AssertionRequestControl |
decodeJSONControl(JSONObject controlObject,
boolean strict)
Attempts to decode the provided object as a JSON representation of an
assertion request control.
|
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.
|
JSONObject |
toJSONControl()
Retrieves a representation of this assertion request control as a JSON
object.
|
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this LDAP control to the provided
buffer.
|
decode, decode, decodeControls, decodeJSONControl, deregisterDecodeableControl, encode, encodeControls, equals, getOID, getValue, hashCode, hasValue, isCritical, readFrom, registerDecodeableControl, registerDecodeableControl, toString, writeTo
@NotNull public static final java.lang.String ASSERTION_REQUEST_OID
public AssertionRequestControl(@NotNull 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(@NotNull Filter filter)
filter
- The filter for this assertion control. It must not be
null
.public AssertionRequestControl(@NotNull 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(@NotNull 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(@NotNull 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.@NotNull public static AssertionRequestControl generate(@NotNull Entry sourceEntry, @Nullable 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.@NotNull public Filter getFilter()
@NotNull public java.lang.String getControlName()
getControlName
in class Control
@NotNull public JSONObject toJSONControl()
oid
-- A mandatory string field whose value is the object
identifier for this control. For the assertion request control, the
OID is "1.3.6.1.1.12".
control-name
-- An optional string field whose value is a
human-readable name for this control. This field is only intended for
descriptive purposes, and when decoding a control, the oid
field should be used to identify the type of control.
criticality
-- A mandatory Boolean field used to indicate
whether this control is considered critical.
value-base64
-- An optional string field whose value is a
base64-encoded representation of the raw value for this assertion
request control. Exactly one of the value-base64
and
value-json
fields must be present.
value-json
-- An optional JSON object field whose value is a
user-friendly representation of the value for this assertion request
control. Exactly one of the value-base64
and
value-json
fields must be present, and if the
value-json
field is used, then it will use the following
fields:
filter
-- A mandatory string field whose value is a string
representation of the assertion filter.
toJSONControl
in class Control
@NotNull public static AssertionRequestControl decodeJSONControl(@NotNull JSONObject controlObject, boolean strict) throws LDAPException
controlObject
- The JSON object to be decoded. It must not be
null
.strict
- Indicates whether to use strict mode when decoding
the provided JSON object. If this is true
,
then this method will throw an exception if the
provided JSON object contains any unrecognized
fields. If this is false
, then unrecognized
fields will be ignored.LDAPException
- If the provided JSON object cannot be parsed as a
valid assertion request control.