Class PasswordPolicyDecorator
- java.lang.Object
-
- org.apache.directory.api.ldap.codec.api.ControlDecorator<PasswordPolicy>
-
- org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyDecorator
-
- All Implemented Interfaces:
Asn1Object
,CodecControl<PasswordPolicy>
,Decorator<PasswordPolicy>
,PasswordPolicy
,Control
public class PasswordPolicyDecorator extends ControlDecorator<PasswordPolicy> implements PasswordPolicy
PasswordPolicy decorator.- Author:
- Apache Directory Project
-
-
Field Summary
-
Fields inherited from interface org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicy
OID
-
-
Constructor Summary
Constructors Constructor Description PasswordPolicyDecorator(LdapApiService codec)
Creates a new instance of PasswordPolicyDecorator.PasswordPolicyDecorator(LdapApiService codec, boolean hasResponse)
Creates a new instance of PasswordPolicyDecorator.PasswordPolicyDecorator(LdapApiService codec, PasswordPolicy policy)
Creates a new instance of PasswordPolicyDecorator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
computeLength()
Compute the object length, which is the sum of all inner length.Asn1Object
decode(byte[] controlBytes)
Decodes raw ASN.1 encoded bytes into an Asn1Object for the control.ByteBuffer
encode(ByteBuffer buffer)
Encode the object to a PDU.PasswordPolicyResponse
getResponse()
Get's the response component of this control if this control carries a response.boolean
hasResponse()
Checks whether this Control is the password policy request or the response by carrying with it an IPasswordPolicyResponse object.PasswordPolicyResponse
setResponse(boolean hasResponse)
If true sets the response to a default newly initialized response object.void
setResponse(PasswordPolicyResponse response)
Sets the response.void
setValue(byte[] value)
Set the encoded control valueString
toString()
Return a String representing a Control-
Methods inherited from class org.apache.directory.api.ldap.codec.api.ControlDecorator
equals, getCodecService, getDecorated, getOid, getValue, hashCode, hasValue, isCritical, setCritical, setDecorated
-
Methods inherited from interface org.apache.directory.api.ldap.model.message.Control
getOid, isCritical, setCritical
-
-
-
-
Constructor Detail
-
PasswordPolicyDecorator
public PasswordPolicyDecorator(LdapApiService codec)
Creates a new instance of PasswordPolicyDecorator.- Parameters:
codec
- The LDAP Service to use
-
PasswordPolicyDecorator
public PasswordPolicyDecorator(LdapApiService codec, boolean hasResponse)
Creates a new instance of PasswordPolicyDecorator.- Parameters:
codec
- The LDAP Service to usehasResponse
- The hasResponse flag
-
PasswordPolicyDecorator
public PasswordPolicyDecorator(LdapApiService codec, PasswordPolicy policy)
Creates a new instance of PasswordPolicyDecorator.- Parameters:
codec
- The LDAP Service to usepolicy
- The asswordPolicy to use
-
-
Method Detail
-
setValue
public void setValue(byte[] value)
Set the encoded control value- Specified by:
setValue
in interfaceCodecControl<PasswordPolicy>
- Overrides:
setValue
in classControlDecorator<PasswordPolicy>
- Parameters:
value
- The encoded control value to store
-
computeLength
public int computeLength()
Compute the object length, which is the sum of all inner length.- Specified by:
computeLength
in interfaceAsn1Object
- Returns:
- The object's computed length
-
encode
public ByteBuffer encode(ByteBuffer buffer) throws EncoderException
Encode the object to a PDU.- Specified by:
encode
in interfaceAsn1Object
- Parameters:
buffer
- The buffer where to put the PDU- Returns:
- The encoded PDU.
- Throws:
EncoderException
- if the buffer can't be encoded
-
toString
public String toString()
Return a String representing a Control- Overrides:
toString
in classControlDecorator<PasswordPolicy>
-
decode
public Asn1Object decode(byte[] controlBytes) throws DecoderException
Decodes raw ASN.1 encoded bytes into an Asn1Object for the control.- Specified by:
decode
in interfaceCodecControl<PasswordPolicy>
- Parameters:
controlBytes
- the encoded control bytes- Returns:
- the decoded Asn1Object for the control
- Throws:
DecoderException
- if anything goes wrong
-
hasResponse
public boolean hasResponse()
Checks whether this Control is the password policy request or the response by carrying with it an IPasswordPolicyResponse object. If it is a request, then no response component will be associated with the control: getResponse() will return null.- Specified by:
hasResponse
in interfacePasswordPolicy
- Returns:
- true if this Control carries a response, false if it is a request
-
setResponse
public void setResponse(PasswordPolicyResponse response)
Sets the response. If null hasResponse() will return null and this will be handled as a password policy request control rather than a response control.- Specified by:
setResponse
in interfacePasswordPolicy
- Parameters:
response
- a valid response object, or null to make this a request
-
setResponse
public PasswordPolicyResponse setResponse(boolean hasResponse)
If true sets the response to a default newly initialized response object. If this was previously a request, it automatically becomes a response. If it was not a request with an already existing response object then that response is replace with a new one and the old is returned. If false then any response object set will be cleared to null. Effectively this will cause hasResponse() to return whatever you plug into it.- Specified by:
setResponse
in interfacePasswordPolicy
- Parameters:
hasResponse
- true to create default response, false to clear it- Returns:
- the old response object, if one did not exist null is returned
-
getResponse
public PasswordPolicyResponse getResponse()
Get's the response component of this control if this control carries a response. IfPasswordPolicy.hasResponse()
returns true, this will return a non-null policy response object.- Specified by:
getResponse
in interfacePasswordPolicy
- Returns:
- a non-null policy response or null, if
PasswordPolicy.hasResponse()
returns false
-
-