Package com.unboundid.ldap.sdk.controls
Class ProxiedAuthorizationV1RequestControl
java.lang.Object
com.unboundid.ldap.sdk.Control
com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV1RequestControl
- All Implemented Interfaces:
Serializable
@NotMutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class ProxiedAuthorizationV1RequestControl
extends Control
This class provides an implementation of the proxied authorization V1
request control, which may be used to request that the associated operation
be performed as if it had been requested by some other user. It is based on
the specification provided in early versions of the
draft-weltman-ldapv3-proxy Internet Draft (this implementation is based on
the "-04" revision). Later versions of the draft, and subsequently
RFC 4370, define a second
version of the proxied authorization control with a different OID and
different value format. This control is supported primarily for legacy
purposes, and it is recommended that new applications use the
The value of this control includes the DN of the user as whom the operation should be performed. Note that it should be a distinguished name, and not an authzId value as is used in the proxied authorization V2 control.
This control may be used in conjunction with add, delete, compare, delete, extended, modify, modify DN, and search requests. In that case, the associated operation will be processed under the authority of the specified authorization identity rather than the identity associated with the client connection (i.e., the user as whom that connection is bound). Note that because of the inherent security risks associated with the use of the proxied authorization control, most directory servers which support its use enforce strict restrictions on the users that are allowed to request this control. Note that while the directory server should return a
There is no corresponding response control for this request control.
ProxiedAuthorizationV2RequestControl instead if this version.
The value of this control includes the DN of the user as whom the operation should be performed. Note that it should be a distinguished name, and not an authzId value as is used in the proxied authorization V2 control.
This control may be used in conjunction with add, delete, compare, delete, extended, modify, modify DN, and search requests. In that case, the associated operation will be processed under the authority of the specified authorization identity rather than the identity associated with the client connection (i.e., the user as whom that connection is bound). Note that because of the inherent security risks associated with the use of the proxied authorization control, most directory servers which support its use enforce strict restrictions on the users that are allowed to request this control. Note that while the directory server should return a
ResultCode.AUTHORIZATION_DENIED result for a proxied authorization V2
control if the requester does not have the appropriate permission to use that
control, this result will not necessarily be used for the same condition with
the proxied authorization V1 control because this result code was not defined
until the release of the proxied authorization V2 specification.
code.
There is no corresponding response control for this request control.
Example
The following example demonstrates the use of the proxied authorization V1 control to delete an entry under the authority of the user with DN "uid=alternate.user,ou=People,dc=example,dc=com":
// Create a delete request to delete an entry. Include the proxied
// authorization v1 request control in the delete request so that the
// delete will be processed as user
// "uid=alternate.user,ou=People,dc=example,dc=com" instead of the user
// that's actually authenticated on the connection.
DeleteRequest deleteRequest =
new DeleteRequest("uid=test.user,ou=People,dc=example,dc=com");
deleteRequest.addControl(new ProxiedAuthorizationV1RequestControl(
"uid=alternate.user,ou=People,dc=example,dc=com"));
LDAPResult deleteResult;
try
{
deleteResult = connection.delete(deleteRequest);
// If we got here, then the delete was successful.
}
catch (LDAPException le)
{
// The delete failed for some reason. In addition to all of the normal
// reasons a delete could fail (e.g., the entry doesn't exist, or has one
// or more subordinates), proxied-authorization specific failures may
// include that the authenticated user doesn't have permission to use the
// proxied authorization control to impersonate the alternate user, that
// the alternate user doesn't exist, or that the alternate user doesn't
// have permission to perform the requested operation.
deleteResult = le.toLDAPResult();
ResultCode resultCode = le.getResultCode();
String errorMessageFromServer = le.getDiagnosticMessage();
}
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe OID (2.16.840.1.113730.3.4.12) for the proxied authorization v1 request control. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new proxied authorization v1 request control which is decoded from the provided generic control.ProxiedAuthorizationV1RequestControl(DN proxyDN) Creates a new proxied authorization V1 request control that will proxy as the specified user.Creates a new proxied authorization V1 request control that will proxy as the specified user. -
Method Summary
Modifier and TypeMethodDescriptiondecodeJSONControl(JSONObject controlObject, boolean strict) Attempts to decode the provided object as a JSON representation of a proxied authorization v1 request control.Retrieves the user-friendly name for this control, if available.Retrieves the DN of the target user under whose authorization the associated request should be performed.Retrieves a representation of this proxied authorization v1 request control as a JSON object.voidtoString(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, decodeJSONControl, deregisterDecodeableControl, encode, encodeControls, equals, getOID, getValue, hashCode, hasValue, isCritical, readFrom, registerDecodeableControl, registerDecodeableControl, toString, writeTo
-
Field Details
-
PROXIED_AUTHORIZATION_V1_REQUEST_OID
The OID (2.16.840.1.113730.3.4.12) for the proxied authorization v1 request control.- See Also:
-
-
Constructor Details
-
ProxiedAuthorizationV1RequestControl
Creates a new proxied authorization V1 request control that will proxy as the specified user.- Parameters:
proxyDN- The DN of the target user under whose authorization the associated request should be performed. It must not benull, although it may be an empty string to request an anonymous authorization.
-
ProxiedAuthorizationV1RequestControl
Creates a new proxied authorization V1 request control that will proxy as the specified user.- Parameters:
proxyDN- The DN of the target user under whose authorization the associated request should be performed. It must not benull.
-
ProxiedAuthorizationV1RequestControl
Creates a new proxied authorization v1 request control which is decoded from the provided generic control.- Parameters:
control- The generic control to be decoded as a proxied authorization v1 request control.- Throws:
LDAPException- If the provided control cannot be decoded as a proxied authorization v1 request control.
-
-
Method Details
-
getProxyDN
Retrieves the DN of the target user under whose authorization the associated request should be performed.- Returns:
- The DN of the target user under whose authorization the associated request should be performed.
-
getControlName
Retrieves the user-friendly name for this control, if available. If no user-friendly name has been defined, then the OID will be returned.- Overrides:
getControlNamein classControl- Returns:
- The user-friendly name for this control, or the OID if no user-friendly name is available.
-
toJSONControl
Retrieves a representation of this proxied authorization v1 request control as a JSON object. The JSON object uses the following fields:-
oid-- A mandatory string field whose value is the object identifier for this control. For the proxied authorization v1 request control, the OID is "2.16.840.1.113730.3.4.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, theoidfield 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 proxied authorization v1 request control. Exactly one of thevalue-base64andvalue-jsonfields must be present. -
value-json-- An optional JSON object field whose value is a user-friendly representation of the value for this proxied authorization v1 request control. Exactly one of thevalue-base64andvalue-jsonfields must be present, and if thevalue-jsonfield is used, then it will use the following fields:-
authorization-dn-- A mandatory string field whose value is the DN of the user as whom the request should be authorized.
-
- Overrides:
toJSONControlin classControl- Returns:
- A JSON object that contains a representation of this control.
-
-
decodeJSONControl
@NotNull public static ProxiedAuthorizationV1RequestControl decodeJSONControl(@NotNull JSONObject controlObject, boolean strict) throws LDAPException Attempts to decode the provided object as a JSON representation of a proxied authorization v1 request control.- Parameters:
controlObject- The JSON object to be decoded. It must not benull.strict- Indicates whether to use strict mode when decoding the provided JSON object. If this istrue, then this method will throw an exception if the provided JSON object contains any unrecognized fields. If this isfalse, then unrecognized fields will be ignored.- Returns:
- The proxied authorization v1 request control that was decoded from the provided JSON object.
- Throws:
LDAPException- If the provided JSON object cannot be parsed as a valid proxied authorization v1 request control.
-
toString
Appends a string representation of this LDAP control to the provided buffer.
-