001 /* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at 010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE 011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Copyright 2006-2008 Sun Microsystems, Inc. 026 */ 027 package org.opends.server.controls; 028 import org.opends.messages.Message; 029 030 031 032 import org.opends.server.protocols.ldap.LDAPResultCode; 033 import org.opends.server.types.Control; 034 import org.opends.server.types.LDAPException; 035 036 import static org.opends.messages.ProtocolMessages.*; 037 import static org.opends.server.util.ServerConstants.*; 038 039 040 041 /** 042 * This class implements the password policy request control defined in 043 * draft-behera-ldap-password-policy. It does not have a value. 044 */ 045 public class PasswordPolicyRequestControl 046 extends Control 047 { 048 049 050 051 /** 052 * Creates a new instance of the password policy request control with the 053 * default settings. 054 */ 055 public PasswordPolicyRequestControl() 056 { 057 super(OID_PASSWORD_POLICY_CONTROL, false); 058 059 } 060 061 062 063 /** 064 * Creates a new instance of the password policy request control with the 065 * provided information. 066 * 067 * @param oid The OID to use for this control. 068 * @param isCritical Indicates whether support for this control should be 069 * considered a critical part of the client processing. 070 */ 071 public PasswordPolicyRequestControl(String oid, boolean isCritical) 072 { 073 super(oid, isCritical); 074 075 } 076 077 078 079 /** 080 * Creates a new password policy request control from the contents of the 081 * provided control. 082 * 083 * @param control The generic control containing the information to use to 084 * create this password policy request control. 085 * 086 * @return The password policy request control decoded from the provided 087 * control. 088 * 089 * @throws LDAPException If this control cannot be decoded as a valid 090 * password policy request control. 091 */ 092 public static PasswordPolicyRequestControl decodeControl(Control control) 093 throws LDAPException 094 { 095 if (control.hasValue()) 096 { 097 Message message = ERR_PWPOLICYREQ_CONTROL_HAS_VALUE.get(); 098 throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); 099 } 100 101 102 return new PasswordPolicyRequestControl(control.getOID(), 103 control.isCritical()); 104 } 105 106 107 108 /** 109 * Retrieves a string representation of this password policy request control. 110 * 111 * @return A string representation of this password policy request control. 112 */ 113 public String toString() 114 { 115 StringBuilder buffer = new StringBuilder(); 116 toString(buffer); 117 return buffer.toString(); 118 } 119 120 121 122 /** 123 * Appends a string representation of this password policy request control to 124 * the provided buffer. 125 * 126 * @param buffer The buffer to which the information should be appended. 127 */ 128 public void toString(StringBuilder buffer) 129 { 130 buffer.append("PasswordPolicyRequestControl()"); 131 } 132 } 133