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