Class ProxiedAuthorizationV1RequestControl

  • All Implemented Interfaces:
    java.io.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 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:
    Serialized Form
    • Constructor Detail

      • ProxiedAuthorizationV1RequestControl

        public ProxiedAuthorizationV1RequestControl​(java.lang.String proxyDN)
        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 be null, although it may be an empty string to request an anonymous authorization.
      • ProxiedAuthorizationV1RequestControl

        public ProxiedAuthorizationV1RequestControl​(DN proxyDN)
        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 be null.
      • ProxiedAuthorizationV1RequestControl

        public ProxiedAuthorizationV1RequestControl​(Control control)
                                             throws LDAPException
        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 Detail

      • getProxyDN

        public java.lang.String 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

        public java.lang.String 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:
        getControlName in class Control
        Returns:
        The user-friendly name for this control, or the OID if no user-friendly name is available.
      • toString

        public void toString​(java.lang.StringBuilder buffer)
        Appends a string representation of this LDAP control to the provided buffer.
        Overrides:
        toString in class Control
        Parameters:
        buffer - The buffer to which to append the string representation of this buffer.