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   *    https://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.ldap.model.message.OpaqueExtendedRequest;
24  
25  
26  /**
27   * 
28   * An extended operation requesting the server to generate a public/private key pair and a certificate
29   * and store them in a specified target entry in the DIT.
30   *
31   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
32   */
33  public class CertGenerationRequestImpl extends OpaqueExtendedRequest implements CertGenerationRequest
34  {
35      /** the Dn of the server entry which will be updated*/
36      private String targetDN;
37  
38      /** the issuer Dn that will be set in the certificate*/
39      private String issuerDN;
40  
41      /** the Dn of the subject that is present in the certificate*/
42      private String subjectDN;
43  
44      /** name of the algorithm used for generating the keys*/
45      private String keyAlgorithm;
46  
47  
48      /**
49       * Creates a new instance of CertGenerationRequest.
50       *
51       * @param messageId the message id
52       * @param targerDN the Dn of target entry whose key and certificate values will be changed
53       * @param issuerDN Dn to be used as the issuer's Dn in the certificate
54       * @param subjectDN Dn to be used as certificate's subject
55       * @param keyAlgorithm crypto algorithm name to be used for generating the keys
56       */
57      public CertGenerationRequestImpl( int messageId, String targerDN, String issuerDN, String subjectDN,
58          String keyAlgorithm )
59      {
60          super( messageId );
61          setRequestName( EXTENSION_OID );
62          this.targetDN = targerDN;
63          this.issuerDN = issuerDN;
64          this.subjectDN = subjectDN;
65          this.keyAlgorithm = keyAlgorithm;
66      }
67  
68  
69      /**
70       * Creates a new instance of CertGenerationRequest.
71       */
72      public CertGenerationRequestImpl()
73      {
74          setRequestName( EXTENSION_OID );
75      }
76  
77  
78      /**
79       * {@inheritDoc}
80       */
81      @Override
82      public String getTargetDN()
83      {
84          return targetDN;
85      }
86  
87  
88      /**
89       * {@inheritDoc}
90       */
91      @Override
92      public void setTargetDN( String targetDN )
93      {
94          this.targetDN = targetDN;
95      }
96  
97  
98      /**
99       * {@inheritDoc}
100      */
101     @Override
102     public String getIssuerDN()
103     {
104         return issuerDN;
105     }
106 
107 
108     /**
109      * {@inheritDoc}
110      */
111     @Override
112     public void setIssuerDN( String issuerDN )
113     {
114         this.issuerDN = issuerDN;
115     }
116 
117 
118     /**
119      * {@inheritDoc}
120      */
121     @Override
122     public String getSubjectDN()
123     {
124         return subjectDN;
125     }
126 
127 
128     /**
129      * {@inheritDoc}
130      */
131     @Override
132     public void setSubjectDN( String subjectDN )
133     {
134         this.subjectDN = subjectDN;
135     }
136 
137 
138     /**
139      * {@inheritDoc}
140      */
141     @Override
142     public String getKeyAlgorithm()
143     {
144         return keyAlgorithm;
145     }
146 
147 
148     /**
149      * {@inheritDoc}
150      */
151     @Override
152     public void setKeyAlgorithm( String keyAlgorithm )
153     {
154         this.keyAlgorithm = keyAlgorithm;
155     }
156 
157 
158     /**
159      * {@inheritDoc}
160      */
161     @Override
162     public CertGenerationResponse getResultResponse()
163     {
164         if ( getResponse() == null )
165         {
166             setResponse( new CertGenerationResponseImpl() );
167         }
168 
169         return ( CertGenerationResponse ) getResponse();
170     }
171 
172 
173     /***
174      * {@inheritDoc}
175      */
176     @Override
177     public String toString()
178     {
179         StringBuilder sb = new StringBuilder();
180         sb.append( "Certficate Generation Object { " ).append( " Target Dn: " ).append( targetDN ).append( ',' );
181         sb.append( " Issuer Dn: " ).append( issuerDN ).append( ',' );
182         sb.append( " Subject Dn: " ).append( subjectDN ).append( ',' );
183         sb.append( " Key Algorithm: " ).append( keyAlgorithm ).append( " }" );
184 
185         return sb.toString();
186     }
187 }