1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.ldap.extras.extended.ads_impl.certGeneration;
21
22
23 import java.nio.ByteBuffer;
24
25 import org.apache.directory.api.asn1.DecoderException;
26 import org.apache.directory.api.asn1.ber.Asn1Decoder;
27 import org.apache.directory.api.asn1.ber.tlv.BerValue;
28 import org.apache.directory.api.asn1.util.Asn1Buffer;
29 import org.apache.directory.api.ldap.codec.api.AbstractExtendedOperationFactory;
30 import org.apache.directory.api.ldap.codec.api.ExtendedOperationFactory;
31 import org.apache.directory.api.ldap.codec.api.LdapApiService;
32 import org.apache.directory.api.ldap.extras.extended.certGeneration.CertGenerationRequest;
33 import org.apache.directory.api.ldap.extras.extended.certGeneration.CertGenerationRequestImpl;
34 import org.apache.directory.api.ldap.extras.extended.certGeneration.CertGenerationResponse;
35 import org.apache.directory.api.ldap.extras.extended.certGeneration.CertGenerationResponseImpl;
36 import org.apache.directory.api.ldap.model.message.ExtendedRequest;
37
38
39
40
41
42
43
44
45 public class CertGenerationFactory extends AbstractExtendedOperationFactory
46 {
47
48
49
50
51
52 public CertGenerationFactory( LdapApiService codec )
53 {
54 super( codec, CertGenerationRequest.EXTENSION_OID );
55 }
56
57
58
59
60
61 @Override
62 public CertGenerationRequest newRequest()
63 {
64 CertGenerationRequest certGenerationRequest = new CertGenerationRequestImpl();
65
66 return certGenerationRequest;
67 }
68
69
70
71
72
73 @Override
74 public CertGenerationRequest newRequest( byte[] encodedValue ) throws DecoderException
75 {
76 CertGenerationRequest certGenerationRequest = new CertGenerationRequestImpl();
77 decodeValue( certGenerationRequest, encodedValue );
78
79 return certGenerationRequest;
80 }
81
82
83
84
85
86 @Override
87 public CertGenerationResponse newResponse()
88 {
89 return new CertGenerationResponseImpl();
90 }
91
92
93
94
95
96 @Override
97 public void decodeValue( ExtendedRequest extendedRequest, byte[] requestValue ) throws DecoderException
98 {
99 ByteBuffer bb = ByteBuffer.wrap( requestValue );
100 CertGenerationRequestContainer container = new CertGenerationRequestContainer();
101 container.setCertGenerationRequest( ( CertGenerationRequest ) extendedRequest );
102 Asn1Decoder.decode( bb, container );
103 }
104
105
106
107
108
109 @Override
110 public void encodeValue( Asn1Buffer buffer, ExtendedRequest extendedRequest )
111 {
112 int start = buffer.getPos();
113 CertGenerationRequest certGenerationRequest = ( CertGenerationRequest ) extendedRequest;
114
115
116 BerValue.encodeOctetString( buffer, certGenerationRequest.getKeyAlgorithm() );
117
118
119 BerValue.encodeOctetString( buffer, certGenerationRequest.getSubjectDN() );
120
121
122 BerValue.encodeOctetString( buffer, certGenerationRequest.getIssuerDN() );
123
124
125 BerValue.encodeOctetString( buffer, certGenerationRequest.getTargetDN() );
126
127
128 BerValue.encodeSequence( buffer, start );
129 }
130 }