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 Sun-defined account usable request control. The 043 * OID for this control is 1.3.6.1.4.1.42.2.27.9.5.8, and it does not have a 044 * value. 045 */ 046 public class AccountUsableRequestControl 047 extends Control 048 { 049 050 051 052 /** 053 * Creates a new instance of the account usable request control with the 054 * default settings. 055 */ 056 public AccountUsableRequestControl() 057 { 058 super(OID_ACCOUNT_USABLE_CONTROL, false); 059 060 } 061 062 063 064 /** 065 * Creates a new instance of the account usable request control with the 066 * provided information. 067 * 068 * @param oid The OID to use for this control. 069 * @param isCritical Indicates whether support for this control should be 070 * considered a critical part of the client processing. 071 */ 072 public AccountUsableRequestControl(String oid, boolean isCritical) 073 { 074 super(oid, isCritical); 075 076 } 077 078 079 080 /** 081 * Creates a new account usable request control from the contents of the 082 * provided control. 083 * 084 * @param control The generic control containing the information to use to 085 * create this account usable request control. 086 * 087 * @return The account usable request control decoded from the provided 088 * control. 089 * 090 * @throws LDAPException If this control cannot be decoded as a valid 091 * account usable request control. 092 */ 093 public static AccountUsableRequestControl decodeControl(Control control) 094 throws LDAPException 095 { 096 if (control.hasValue()) 097 { 098 Message message = ERR_ACCTUSABLEREQ_CONTROL_HAS_VALUE.get(); 099 throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); 100 } 101 102 103 return new AccountUsableRequestControl(control.getOID(), 104 control.isCritical()); 105 } 106 107 108 109 /** 110 * Retrieves a string representation of this account usable request control. 111 * 112 * @return A string representation of this account usable request control. 113 */ 114 public String toString() 115 { 116 StringBuilder buffer = new StringBuilder(); 117 toString(buffer); 118 return buffer.toString(); 119 } 120 121 122 123 /** 124 * Appends a string representation of this account usable request control to 125 * the provided buffer. 126 * 127 * @param buffer The buffer to which the information should be appended. 128 */ 129 public void toString(StringBuilder buffer) 130 { 131 buffer.append("AccountUsableRequestControl()"); 132 } 133 } 134