001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 *
019 */
020 package org.apache.directory.shared.ldap.message.extended;
021
022 import org.apache.directory.shared.ldap.message.ExtendedResponseImpl;
023 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
024 import org.apache.directory.shared.ldap.util.StringTools;
025 /**
026 *
027 * The response sent back from the server after the CertGeneration extended operation is performed.
028 *
029 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
030 * @version $Rev$, $Date$
031 */
032 public class CertGenerationResponse extends ExtendedResponseImpl
033 {
034 /** The serial version UUID */
035 private static final long serialVersionUID = 1L;
036
037 /** The CertGenerationResponse OID */
038 public static final String EXTENSION_OID = "1.3.6.1.4.1.18060.0.1.9";
039
040 public CertGenerationResponse(int messageId, ResultCodeEnum rcode)
041 {
042 super( messageId, EXTENSION_OID );
043
044 switch ( rcode )
045 {
046 case SUCCESS :
047 case OPERATIONS_ERROR :
048 case INSUFFICIENT_ACCESS_RIGHTS :
049 break;
050
051 default:
052 throw new IllegalArgumentException( "The result code can only be one of: " + ResultCodeEnum.SUCCESS
053 + ", " + ResultCodeEnum.OPERATIONS_ERROR + ", " + ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
054 }
055
056 super.getLdapResult().setMatchedDn( null );
057 super.getLdapResult().setResultCode( rcode );
058 }
059
060
061 public CertGenerationResponse(int messageId)
062 {
063 super( messageId, EXTENSION_OID );
064 super.getLdapResult().setMatchedDn( null );
065 super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
066 }
067
068
069 // ------------------------------------------------------------------------
070 // ExtendedResponse Interface Method Implementations
071 // ------------------------------------------------------------------------
072
073 /**
074 * Gets the reponse OID specific encoded response values.
075 *
076 * @return the response specific encoded response values.
077 */
078 public byte[] getResponse()
079 {
080 return StringTools.EMPTY_BYTES;
081 }
082
083
084 /**
085 * Sets the response OID specific encoded response values.
086 *
087 * @param value
088 * the response specific encoded response values.
089 */
090 public void setResponse( byte[] value )
091 {
092 // do nothing here instead
093 }
094
095
096 /**
097 * Gets the OID uniquely identifying this extended response (a.k.a. its
098 * name).
099 *
100 * @return the OID of the extended response type.
101 */
102 public String getResponseName()
103 {
104 return EXTENSION_OID;
105 }
106
107
108 /**
109 * Sets the OID uniquely identifying this extended response (a.k.a. its
110 * name).
111 *
112 * @param oid
113 * the OID of the extended response type.
114 */
115 public void setResponseName( String oid )
116 {
117 throw new UnsupportedOperationException( "the OID is fixed: " + EXTENSION_OID );
118 }
119
120
121 public boolean equals( Object obj )
122 {
123 if ( obj == this )
124 {
125 return true;
126 }
127
128 if ( obj instanceof CertGenerationResponse )
129 {
130 return true;
131 }
132
133 return false;
134 }
135 }