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 */ 020package org.apache.directory.api.ldap.extras.extended.certGeneration; 021 022 023import org.apache.directory.api.ldap.model.message.AbstractExtendedRequest; 024 025 026/** 027 * 028 * An extended operation requesting the server to generate a public/private key pair and a certificate 029 * and store them in a specified target entry in the DIT. 030 * 031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 032 */ 033public class CertGenerationRequestImpl extends AbstractExtendedRequest implements 034 CertGenerationRequest 035{ 036 /** the Dn of the server entry which will be updated*/ 037 private String targetDN; 038 039 /** the issuer Dn that will be set in the certificate*/ 040 private String issuerDN; 041 042 /** the Dn of the subject that is present in the certificate*/ 043 private String subjectDN; 044 045 /** name of the algorithm used for generating the keys*/ 046 private String keyAlgorithm; 047 048 049 /** 050 * Creates a new instance of CertGenerationRequest. 051 * 052 * @param messageId the message id 053 * @param targerDN the Dn of target entry whose key and certificate values will be changed 054 * @param issuerDN Dn to be used as the issuer's Dn in the certificate 055 * @param subjectDN Dn to be used as certificate's subject 056 * @param keyAlgorithm crypto algorithm name to be used for generating the keys 057 */ 058 public CertGenerationRequestImpl( int messageId, String targerDN, String issuerDN, String subjectDN, 059 String keyAlgorithm ) 060 { 061 super( messageId ); 062 setRequestName( EXTENSION_OID ); 063 this.targetDN = targerDN; 064 this.issuerDN = issuerDN; 065 this.subjectDN = subjectDN; 066 this.keyAlgorithm = keyAlgorithm; 067 } 068 069 070 /** 071 * Creates a new instance of CertGenerationRequest. 072 */ 073 public CertGenerationRequestImpl() 074 { 075 setRequestName( EXTENSION_OID ); 076 } 077 078 079 /** 080 * {@inheritDoc} 081 */ 082 @Override 083 public String getTargetDN() 084 { 085 return targetDN; 086 } 087 088 089 /** 090 * {@inheritDoc} 091 */ 092 @Override 093 public void setTargetDN( String targetDN ) 094 { 095 this.targetDN = targetDN; 096 } 097 098 099 /** 100 * {@inheritDoc} 101 */ 102 @Override 103 public String getIssuerDN() 104 { 105 return issuerDN; 106 } 107 108 109 /** 110 * {@inheritDoc} 111 */ 112 @Override 113 public void setIssuerDN( String issuerDN ) 114 { 115 this.issuerDN = issuerDN; 116 } 117 118 119 /** 120 * {@inheritDoc} 121 */ 122 @Override 123 public String getSubjectDN() 124 { 125 return subjectDN; 126 } 127 128 129 /** 130 * {@inheritDoc} 131 */ 132 @Override 133 public void setSubjectDN( String subjectDN ) 134 { 135 this.subjectDN = subjectDN; 136 } 137 138 139 /** 140 * {@inheritDoc} 141 */ 142 @Override 143 public String getKeyAlgorithm() 144 { 145 return keyAlgorithm; 146 } 147 148 149 /** 150 * {@inheritDoc} 151 */ 152 @Override 153 public void setKeyAlgorithm( String keyAlgorithm ) 154 { 155 this.keyAlgorithm = keyAlgorithm; 156 } 157 158 159 @Override 160 public CertGenerationResponse getResultResponse() 161 { 162 if ( getResponse() == null ) 163 { 164 setResponse( new CertGenerationResponseImpl() ); 165 } 166 167 return ( CertGenerationResponse ) getResponse(); 168 } 169 170 171 @Override 172 public String toString() 173 { 174 StringBuilder sb = new StringBuilder(); 175 sb.append( "Certficate Generation Object { " ).append( " Target Dn: " ).append( targetDN ).append( ',' ); 176 sb.append( " Issuer Dn: " ).append( issuerDN ).append( ',' ); 177 sb.append( " Subject Dn: " ).append( subjectDN ).append( ',' ); 178 sb.append( " Key Algorithm: " ).append( keyAlgorithm ).append( " }" ); 179 180 return sb.toString(); 181 } 182}