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.codec.controls.proxiedauthz;
21
22
23 import org.apache.directory.api.asn1.DecoderException;
24 import org.apache.directory.api.asn1.util.Asn1Buffer;
25 import org.apache.directory.api.ldap.codec.api.AbstractControlFactory;
26 import org.apache.directory.api.ldap.codec.api.ControlFactory;
27 import org.apache.directory.api.ldap.codec.api.LdapApiService;
28 import org.apache.directory.api.ldap.model.message.Control;
29 import org.apache.directory.api.ldap.model.message.controls.ProxiedAuthz;
30 import org.apache.directory.api.ldap.model.message.controls.ProxiedAuthzImpl;
31 import org.apache.directory.api.util.Strings;
32
33
34
35
36
37
38
39
40 public class ProxiedAuthzFactory extends AbstractControlFactory<ProxiedAuthz>
41 {
42
43
44
45
46
47 public ProxiedAuthzFactory( LdapApiService codec )
48 {
49 super( codec, ProxiedAuthz.OID );
50 }
51
52
53
54
55
56 @Override
57 public ProxiedAuthz newControl()
58 {
59 return new ProxiedAuthzImpl();
60 }
61
62
63
64
65
66 @Override
67 public void encodeValue( Asn1Buffer buffer, Control control )
68 {
69 byte[] authzId = Strings.getBytesUtf8( ( ( ProxiedAuthz ) control ).getAuthzId() );
70
71 if ( authzId != null )
72 {
73 buffer.put( authzId );
74 }
75 }
76
77
78
79
80
81 public void decodeValue( Control control, byte[] controlBytes ) throws DecoderException
82 {
83 try
84 {
85 ( ( ProxiedAuthz ) control ).setAuthzId( Strings.utf8ToString( controlBytes ) );
86 }
87 catch ( RuntimeException re )
88 {
89 throw new DecoderException( re.getMessage() );
90 }
91 }
92 }