org.apache.directory.shared.ldap.extras.controls.ppolicy_impl
Class PasswordPolicyDecorator

java.lang.Object
  extended by org.apache.directory.shared.asn1.AbstractAsn1Object
      extended by org.apache.directory.shared.ldap.codec.controls.ControlDecorator<PasswordPolicy>
          extended by org.apache.directory.shared.ldap.extras.controls.ppolicy_impl.PasswordPolicyDecorator
All Implemented Interfaces:
Asn1Object, CodecControl<PasswordPolicy>, Decorator<PasswordPolicy>, PasswordPolicy, Control

public class PasswordPolicyDecorator
extends ControlDecorator<PasswordPolicy>
implements PasswordPolicy

PasswordPolicyResponseControl.

Author:
Apache Directory Project

Field Summary
 
Fields inherited from class org.apache.directory.shared.ldap.codec.controls.ControlDecorator
value
 
Fields inherited from interface org.apache.directory.shared.ldap.extras.controls.PasswordPolicy
OID
 
Constructor Summary
PasswordPolicyDecorator(LdapCodecService codec)
           
PasswordPolicyDecorator(LdapCodecService codec, boolean hasResponse)
           
PasswordPolicyDecorator(LdapCodecService codec, PasswordPolicy policy)
           
 
Method Summary
 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 value
 String toString()
          Return a String representing a Control
 
Methods inherited from class org.apache.directory.shared.ldap.codec.controls.ControlDecorator
equals, getCodecService, getDecorated, getOid, getValue, hashCode, hasValue, isCritical, setCritical, setDecorated
 
Methods inherited from class org.apache.directory.shared.asn1.AbstractAsn1Object
addLength, getCurrentLength, getExpectedLength, getParent, getTlvId, setCurrentLength, setExpectedLength, setParent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.directory.shared.ldap.model.message.Control
getOid, isCritical, setCritical
 

Constructor Detail

PasswordPolicyDecorator

public PasswordPolicyDecorator(LdapCodecService codec)

PasswordPolicyDecorator

public PasswordPolicyDecorator(LdapCodecService codec,
                               boolean hasResponse)

PasswordPolicyDecorator

public PasswordPolicyDecorator(LdapCodecService codec,
                               PasswordPolicy policy)
Method Detail

setValue

public void setValue(byte[] value)
Set the encoded control value

Specified by:
setValue in interface CodecControl<PasswordPolicy>
Overrides:
setValue in class ControlDecorator<PasswordPolicy>
Parameters:
value - The encoded control value to store

computeLength

public int computeLength()
Description copied from class: ControlDecorator
Compute the object length, which is the sum of all inner length.

Specified by:
computeLength in interface Asn1Object
Specified by:
computeLength in interface Decorator<PasswordPolicy>
Overrides:
computeLength in class ControlDecorator<PasswordPolicy>
Returns:
The object's computed length

encode

public ByteBuffer encode(ByteBuffer buffer)
                  throws EncoderException
Description copied from interface: Decorator
Encode the object to a PDU.

Specified by:
encode in interface Asn1Object
Specified by:
encode in interface Decorator<PasswordPolicy>
Overrides:
encode in class AbstractAsn1Object
Parameters:
buffer - The buffer where to put the PDU
Returns:
The PDU.
Throws:
EncoderException - if the buffer can't be encoded

toString

public String toString()
Description copied from class: ControlDecorator
Return a String representing a Control

Overrides:
toString in class ControlDecorator<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 interface CodecControl<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 interface PasswordPolicy
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 interface PasswordPolicy
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 interface PasswordPolicy
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. If PasswordPolicy.hasResponse() returns true, this will return a non-null policy response object.

Specified by:
getResponse in interface PasswordPolicy
Returns:
a non-null policy response or null, if PasswordPolicy.hasResponse() returns false


Copyright © 2003-2011 The Apache Software Foundation. All Rights Reserved.