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 org.apache.directory.api.asn1.DecoderException;
24 import org.apache.directory.api.ldap.codec.api.ExtendedOperationFactory;
25 import org.apache.directory.api.ldap.codec.api.LdapApiService;
26 import org.apache.directory.api.ldap.extras.extended.certGeneration.CertGenerationRequest;
27 import org.apache.directory.api.ldap.extras.extended.certGeneration.CertGenerationRequestImpl;
28 import org.apache.directory.api.ldap.extras.extended.certGeneration.CertGenerationResponse;
29 import org.apache.directory.api.ldap.extras.extended.certGeneration.CertGenerationResponseImpl;
30 import org.apache.directory.api.ldap.model.message.ExtendedRequest;
31 import org.apache.directory.api.ldap.model.message.ExtendedResponse;
32
33
34
35
36
37
38
39
40 public class CertGenerationFactory implements ExtendedOperationFactory
41 {
42 private LdapApiService codec;
43
44
45 public CertGenerationFactory( LdapApiService codec )
46 {
47 this.codec = codec;
48 }
49
50
51
52
53
54 public String getOid()
55 {
56 return CertGenerationRequest.EXTENSION_OID;
57 }
58
59
60
61
62
63 public CertGenerationResponse newResponse( byte[] encodedValue ) throws DecoderException
64 {
65 CertGenerationResponseDecorator response = new CertGenerationResponseDecorator( codec,
66 new CertGenerationResponseImpl() );
67 response.setResponseValue( encodedValue );
68
69 return response;
70 }
71
72
73
74
75
76 public CertGenerationRequest newRequest( byte[] value )
77 {
78 CertGenerationRequestDecorator req = new CertGenerationRequestDecorator( codec, new CertGenerationRequestImpl() );
79 req.setRequestValue( value );
80 return req;
81 }
82
83
84
85
86
87 public CertGenerationRequestDecorator decorate( ExtendedRequest modelRequest )
88 {
89 if ( modelRequest instanceof CertGenerationRequestDecorator )
90 {
91 return ( CertGenerationRequestDecorator ) modelRequest;
92 }
93
94 return new CertGenerationRequestDecorator( codec, ( CertGenerationRequest ) modelRequest );
95 }
96
97
98
99
100
101 public CertGenerationResponseDecorator decorate( ExtendedResponse decoratedMessage )
102 {
103 if ( decoratedMessage instanceof CertGenerationResponseDecorator )
104 {
105 return ( CertGenerationResponseDecorator ) decoratedMessage;
106 }
107
108 return new CertGenerationResponseDecorator( codec, ( CertGenerationResponse ) decoratedMessage );
109 }
110 }