/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2009 Sun Microsystems, Inc.
* Portions copyright 2011 ForgeRock AS.
*/
/**
* This class implements the password policy response control defined in
* draft-behera-ldap-password-policy. The value may have zero, one, or two
*/
public class PasswordPolicyResponseControl
extends Control
{
/**
* ControlDecoder implentation to decode this control from a ByteString.
*/
private final static class Decoder
implements ControlDecoder<PasswordPolicyResponseControl>
{
/**
* {@inheritDoc}
*/
throws DirectoryException
{
{
// The response control must always have a value.
}
try
{
int warningValue = -1;
if(reader.hasNextElement() &&
{
// Its a CHOICE element. Read as sequence to retrieve
// nested element.
if (warningType == null)
{
message);
}
}
if(reader.hasNextElement() &&
{
{
message);
}
}
return new PasswordPolicyResponseControl(isCritical,
}
catch (DirectoryException de)
{
throw de;
}
catch (Exception e)
{
if (debugEnabled())
{
}
}
}
{
return OID_ACCOUNT_USABLE_CONTROL;
}
}
/**
* The Control Decoder that can be used to decode this control.
*/
new Decoder();
/**
* The tracer object for the debug logger.
*/
/**
* The BER type value for the warning element of the control value.
*/
/**
* The BER type value for the error element of the control value.
*/
// The warning value for this password policy response control.
private int warningValue;
// The error type for this password policy response control.
// The warning type for the password policy response control.
/**
* Creates a new instance of the password policy response control with the
* default OID and criticality, and without either a warning or an error flag.
*/
public PasswordPolicyResponseControl()
{
}
/**
* Creates a new instance of this password policy response control with the
* flag information.
*
* @param warningType The warning type to use for this password policy
* response control, or <CODE>null</CODE> if there
* should not be a warning flag.
* @param warningValue The warning value to use for this password policy
* response control, if applicable.
* @param errorType The error type to use for this password policy
* response control, or <CODE>null</CODE> if there
* should not be an error flag.
*/
int warningValue,
{
}
/**
* Creates a new instance of the password policy request control with the
* provided information.
*
* @param isCritical Indicates whether support for this control should be
* considered a critical part of the client processing.
* @param warningType The warning type to use for this password policy
* response control, or <CODE>null</CODE> if there
* should not be a warning flag.
* @param warningValue The warning value to use for this password policy
* response control, if applicable.
* @param errorType The error type to use for this password policy
* response control, or <CODE>null</CODE> if there
* should not be an error flag.
*/
int warningValue,
{
super(OID_PASSWORD_POLICY_CONTROL, isCritical);
this.warningType = warningType;
this.warningValue = warningValue;
}
/**
* Writes this control's value to an ASN.1 writer. The value (if any) must be
* written as an ASN1OctetString.
*
* @param writer The ASN.1 writer to use.
* @throws IOException If a problem occurs while writing to the stream.
*/
if (warningType != null)
{
// Just write the CHOICE element as a single element SEQUENCE.
}
{
}
}
/**
* Retrieves the password policy warning type contained in this control.
*
* @return The password policy warning type contained in this control, or
* <CODE>null</CODE> if there is no warning type.
*/
{
return warningType;
}
/**
* Retrieves the password policy warning value for this control. The value is
* undefined if there is no warning type.
*
* @return The password policy warning value for this control.
*/
public int getWarningValue()
{
return warningValue;
}
/**
* Retrieves the password policy error type contained in this control.
*
* @return The password policy error type contained in this control, or
* <CODE>null</CODE> if there is no error type.
*/
{
return errorType;
}
/**
* Appends a string representation of this password policy response control to
* the provided buffer.
*
* @param buffer The buffer to which the information should be appended.
*/
{
if (warningType != null)
{
{
}
}
{
}
}
}