001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2006-2008 Sun Microsystems, Inc. 015 * Portions Copyright 2014-2015 ForgeRock AS. 016 */ 017package org.opends.server.controls; 018import org.forgerock.i18n.LocalizableMessage; 019 020 021 022import org.forgerock.opendj.io.ASN1Writer; 023import org.forgerock.opendj.ldap.ByteString; 024import org.opends.server.types.Control; 025import org.opends.server.types.DirectoryException; 026import org.forgerock.opendj.ldap.ResultCode; 027 028import static org.opends.messages.ProtocolMessages.*; 029import static org.opends.server.util.ServerConstants.*; 030 031import java.io.IOException; 032 033 034/** 035 * This class implements the Sun-defined account usable request control. The 036 * OID for this control is 1.3.6.1.4.1.42.2.27.9.5.8, and it does not have a 037 * value. 038 */ 039public class AccountUsableRequestControl 040 extends Control 041{ 042 /** 043 * ControlDecoder implementation to decode this control from a ByteString. 044 */ 045 private static final class Decoder 046 implements ControlDecoder<AccountUsableRequestControl> 047 { 048 /** {@inheritDoc} */ 049 public AccountUsableRequestControl decode(boolean isCritical, 050 ByteString value) 051 throws DirectoryException 052 { 053 if (value != null) 054 { 055 LocalizableMessage message = ERR_ACCTUSABLEREQ_CONTROL_HAS_VALUE.get(); 056 throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message); 057 } 058 059 060 return new AccountUsableRequestControl(isCritical); 061 } 062 063 public String getOID() 064 { 065 return OID_ACCOUNT_USABLE_CONTROL; 066 } 067 068 } 069 070 /** 071 * The Control Decoder that can be used to decode this control. 072 */ 073 public static final ControlDecoder<AccountUsableRequestControl> DECODER = 074 new Decoder(); 075 076 /** 077 * Creates a new instance of the account usable request control with the 078 * default settings. 079 */ 080 public AccountUsableRequestControl() 081 { 082 this(false); 083 } 084 085 /** 086 * Creates a new instance of the account usable request control with the 087 * default settings. 088 * 089 * @param isCritical Indicates whether this control should be 090 * considered critical in processing the 091 * request. 092 */ 093 public AccountUsableRequestControl(boolean isCritical) 094 { 095 super(OID_ACCOUNT_USABLE_CONTROL, isCritical); 096 097 } 098 099 /** 100 * Writes this control's value to an ASN.1 writer. The value (if any) must be 101 * written as an ASN1OctetString. 102 * 103 * @param writer The ASN.1 output stream to write to. 104 * @throws IOException If a problem occurs while writing to the stream. 105 */ 106 protected void writeValue(ASN1Writer writer) throws IOException { 107 // No value element. 108 } 109 110 111 112 /** 113 * Appends a string representation of this account usable request control to 114 * the provided buffer. 115 * 116 * @param buffer The buffer to which the information should be appended. 117 */ 118 public void toString(StringBuilder buffer) 119 { 120 buffer.append("AccountUsableRequestControl()"); 121 } 122} 123