| | |
| | | |
| | | |
| | | |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.protocols.asn1.ASN1Writer; |
| | | import org.opends.server.types.ByteString; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.messages.ProtocolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | |
| | | /** |
| | |
| | | public class PasswordPolicyRequestControl |
| | | extends Control |
| | | { |
| | | /** |
| | | * ControlDecoder implentation to decode this control from a ByteString. |
| | | */ |
| | | private final static class Decoder |
| | | implements ControlDecoder<PasswordPolicyRequestControl> |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public PasswordPolicyRequestControl decode(boolean isCritical, |
| | | ByteString value) |
| | | throws DirectoryException |
| | | { |
| | | if (value != null) |
| | | { |
| | | Message message = ERR_PWPOLICYREQ_CONTROL_HAS_VALUE.get(); |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | |
| | | |
| | | return new PasswordPolicyRequestControl(isCritical); |
| | | } |
| | | |
| | | public String getOID() |
| | | { |
| | | return OID_PASSWORD_POLICY_CONTROL; |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * The Control Decoder that can be used to decode this control. |
| | | */ |
| | | public static final ControlDecoder<PasswordPolicyRequestControl> DECODER = |
| | | new Decoder(); |
| | | |
| | | |
| | | /** |
| | | * Creates a new instance of the password policy request control with the |
| | |
| | | */ |
| | | public PasswordPolicyRequestControl() |
| | | { |
| | | super(OID_PASSWORD_POLICY_CONTROL, false); |
| | | this(false); |
| | | |
| | | } |
| | | |
| | |
| | | * Creates a new instance of the password policy request control with the |
| | | * provided information. |
| | | * |
| | | * @param oid The OID to use for this control. |
| | | * @param isCritical Indicates whether support for this control should be |
| | | * considered a critical part of the client processing. |
| | | */ |
| | | public PasswordPolicyRequestControl(String oid, boolean isCritical) |
| | | public PasswordPolicyRequestControl(boolean isCritical) |
| | | { |
| | | super(oid, isCritical); |
| | | super(OID_PASSWORD_POLICY_CONTROL, isCritical); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new password policy request control from the contents of the |
| | | * provided control. |
| | | * Writes this control's value to an ASN.1 writer. The value (if any) must be |
| | | * written as an ASN1OctetString. |
| | | * |
| | | * @param control The generic control containing the information to use to |
| | | * create this password policy request control. |
| | | * |
| | | * @return The password policy request control decoded from the provided |
| | | * control. |
| | | * |
| | | * @throws LDAPException If this control cannot be decoded as a valid |
| | | * password policy request control. |
| | | * @param writer The ASN.1 output stream to write to. |
| | | * @throws IOException If a problem occurs while writing to the stream. |
| | | */ |
| | | public static PasswordPolicyRequestControl decodeControl(Control control) |
| | | throws LDAPException |
| | | { |
| | | if (control.hasValue()) |
| | | { |
| | | Message message = ERR_PWPOLICYREQ_CONTROL_HAS_VALUE.get(); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | |
| | | |
| | | return new PasswordPolicyRequestControl(control.getOID(), |
| | | control.isCritical()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves a string representation of this password policy request control. |
| | | * |
| | | * @return A string representation of this password policy request control. |
| | | */ |
| | | public String toString() |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | toString(buffer); |
| | | return buffer.toString(); |
| | | @Override |
| | | public void writeValue(ASN1Writer writer) throws IOException { |
| | | // No value element. |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * @param buffer The buffer to which the information should be appended. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer) |
| | | { |
| | | buffer.append("PasswordPolicyRequestControl()"); |