View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.api.ldap.extras.extended.certGeneration;
21  
22  
23  import org.apache.directory.api.i18n.I18n;
24  import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
25  import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
26  
27  
28  /**
29   * 
30   * The response sent back from the server after the CertGeneration extended operation is performed.
31   *
32   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
33   */
34  public class CertGenerationResponseImpl extends ExtendedResponseImpl implements CertGenerationResponse
35  {
36      public CertGenerationResponseImpl( int messageId, ResultCodeEnum rcode )
37      {
38          super( messageId, EXTENSION_OID );
39  
40          switch ( rcode )
41          {
42              case SUCCESS:
43              case OPERATIONS_ERROR:
44              case INSUFFICIENT_ACCESS_RIGHTS:
45                  break;
46  
47              default:
48                  throw new IllegalArgumentException( I18n.err( I18n.ERR_04166, ResultCodeEnum.SUCCESS,
49                      ResultCodeEnum.OPERATIONS_ERROR, ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS ) );
50          }
51  
52          super.getLdapResult().setMatchedDn( null );
53          super.getLdapResult().setResultCode( rcode );
54      }
55  
56  
57      public CertGenerationResponseImpl( int messageId )
58      {
59          super( messageId, EXTENSION_OID );
60          super.getLdapResult().setMatchedDn( null );
61          super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
62      }
63  
64  
65      public CertGenerationResponseImpl()
66      {
67          super( EXTENSION_OID );
68          super.getLdapResult().setMatchedDn( null );
69          super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
70      }
71  
72  
73      /**
74       * Gets the OID uniquely identifying this extended response (a.k.a. its
75       * name).
76       * 
77       * @return the OID of the extended response type.
78       */
79      public String getResponseName()
80      {
81          return EXTENSION_OID;
82      }
83  
84  
85      /**
86       * Sets the OID uniquely identifying this extended response (a.k.a. its
87       * name).
88       * 
89       * @param oid
90       *            the OID of the extended response type.
91       */
92      public void setResponseName( String oid )
93      {
94          throw new UnsupportedOperationException( I18n.err( I18n.ERR_04168, EXTENSION_OID ) );
95      }
96  
97  
98      /**
99       * {@inheritDoc}
100      */
101     @Override
102     public int hashCode()
103     {
104         int hash = 37;
105         // Seems simple but look at the equals() method ...
106         hash = hash * 17 + getClass().getName().hashCode();
107 
108         return hash;
109     }
110 
111 
112     /**
113      * {@inheritDoc}
114      */
115     @Override
116     public boolean equals( Object obj )
117     {
118         if ( obj == this )
119         {
120             return true;
121         }
122 
123         return ( obj instanceof CertGenerationResponseImpl );
124     }
125 }