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.i18n.I18n;
023    import org.apache.directory.shared.ldap.message.ExtendedResponseImpl;
024    import org.apache.directory.shared.ldap.message.ResultCodeEnum;
025    import org.apache.directory.shared.ldap.util.StringTools;
026    /**
027     * 
028     * The response sent back from the server after the CertGeneration extended operation is performed.
029     *
030     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
031     * @version $Rev$, $Date$
032     */
033    public class CertGenerationResponse extends ExtendedResponseImpl
034    {
035        /** The serial version UUID */
036        private static final long serialVersionUID = 1L;
037        
038        /** The CertGenerationResponse OID */
039        public static final String EXTENSION_OID = "1.3.6.1.4.1.18060.0.1.9";
040    
041        public CertGenerationResponse(int messageId, ResultCodeEnum rcode)
042        {
043            super( messageId, EXTENSION_OID );
044    
045            switch ( rcode )
046            {
047                case SUCCESS :
048                case OPERATIONS_ERROR :
049                case INSUFFICIENT_ACCESS_RIGHTS :
050                    break;
051                
052                default:
053                    throw new IllegalArgumentException( I18n.err( I18n.ERR_04166, ResultCodeEnum.SUCCESS,
054                                    ResultCodeEnum.OPERATIONS_ERROR, ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS ) );
055            }
056            
057            super.getLdapResult().setMatchedDn( null );
058            super.getLdapResult().setResultCode( rcode );
059        }
060    
061    
062        public CertGenerationResponse(int messageId)
063        {
064            super( messageId, EXTENSION_OID );
065            super.getLdapResult().setMatchedDn( null );
066            super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
067        }
068    
069    
070        // ------------------------------------------------------------------------
071        // ExtendedResponse Interface Method Implementations
072        // ------------------------------------------------------------------------
073    
074        /**
075         * Gets the reponse OID specific encoded response values.
076         * 
077         * @return the response specific encoded response values.
078         */
079        public byte[] getResponse()
080        {
081            return StringTools.EMPTY_BYTES;
082        }
083    
084    
085        /**
086         * Sets the response OID specific encoded response values.
087         * 
088         * @param value
089         *            the response specific encoded response values.
090         */
091        public void setResponse( byte[] value )
092        {
093            // do nothing here instead
094        }
095    
096    
097        /**
098         * Gets the OID uniquely identifying this extended response (a.k.a. its
099         * name).
100         * 
101         * @return the OID of the extended response type.
102         */
103        public String getResponseName()
104        {
105            return EXTENSION_OID;
106        }
107    
108    
109        /**
110         * Sets the OID uniquely identifying this extended response (a.k.a. its
111         * name).
112         * 
113         * @param oid
114         *            the OID of the extended response type.
115         */
116        public void setResponseName( String oid )
117        {
118            throw new UnsupportedOperationException( I18n.err( I18n.ERR_04168, EXTENSION_OID ) );
119        }
120    
121    
122        public boolean equals( Object obj )
123        {
124            if ( obj == this )
125            {
126                return true;
127            }
128    
129            if ( obj instanceof CertGenerationResponse )
130            {
131                return true;
132            }
133    
134            return false;
135        }
136    }