1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.kerberos.client;
21
22
23 import java.net.InetAddress;
24 import java.net.UnknownHostException;
25 import java.util.ArrayList;
26 import java.util.List;
27 import java.util.Set;
28
29 import org.apache.directory.shared.kerberos.codec.options.KdcOptions;
30 import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
31 import org.apache.directory.shared.kerberos.components.HostAddress;
32
33
34 public class TgtRequest
35 {
36 private String clientPrincipal;
37 private String password;
38 private String realm;
39 private String serverPrincipal;
40
41 private long startTime;
42
43 private long expiryTime;
44
45 private long renewTill;
46
47 private List<HostAddress> hostAddresses = new ArrayList<>();
48
49 private KdcOptionsrberos/codec/options/KdcOptions.html#KdcOptions">KdcOptions options = new KdcOptions();
50
51 private boolean preAuthEnabled = false;
52
53
54 private Set<EncryptionType> eTypes;
55
56
57 public TgtRequest()
58 {
59 startTime = System.currentTimeMillis();
60 expiryTime = startTime + ( 8 * 60 * 60 * 1000 );
61 }
62
63
64 public void addHost( String hostNameOrIpAddress ) throws UnknownHostException
65 {
66 InetAddress address = InetAddress.getByName( hostNameOrIpAddress );
67 hostAddresses.add( new HostAddress( address ) );
68 }
69
70
71 public String getPassword()
72 {
73 return password;
74 }
75
76
77 public void setPassword( String password )
78 {
79 this.password = password;
80 }
81
82
83 public String getClientPrincipal()
84 {
85 return clientPrincipal;
86 }
87
88
89 public void setClientPrincipal( String clientPrincipal )
90 {
91 this.clientPrincipal = clientPrincipal;
92 realm = KdcClientUtil.extractRealm( clientPrincipal );
93 }
94
95
96 public String getRealm()
97 {
98 return realm;
99 }
100
101
102 public String getServerPrincipal()
103 {
104 return serverPrincipal;
105 }
106
107
108 public void setServerPrincipal( String serverPrincipal )
109 {
110 this.serverPrincipal = serverPrincipal;
111 }
112
113
114 public long getStartTime()
115 {
116 return startTime;
117 }
118
119
120 public void setStartTime( long startTime )
121 {
122 this.startTime = startTime;
123 }
124
125
126 public long getExpiryTime()
127 {
128 return expiryTime;
129 }
130
131
132 public void setExpiryTime( long expiryTime )
133 {
134 this.expiryTime = expiryTime;
135 }
136
137
138 public long getRenewTill()
139 {
140 return renewTill;
141 }
142
143
144 public void setRenewTill( long renewTill )
145 {
146 this.renewTill = renewTill;
147 }
148
149
150 public List<HostAddress> getHostAddresses()
151 {
152 return hostAddresses;
153 }
154
155
156 public void setForwardable( boolean forwardable )
157 {
158 setOrClear( KdcOptions.FORWARDABLE, forwardable );
159 }
160
161
162 public void setProxiable( boolean proxiable )
163 {
164 setOrClear( KdcOptions.PROXIABLE, proxiable );
165 }
166
167
168 public void setAllowPostdate( boolean allowPostdate )
169 {
170 setOrClear( KdcOptions.ALLOW_POSTDATE, allowPostdate );
171 }
172
173
174 public void setPostdated( boolean postdated )
175 {
176 setOrClear( KdcOptions.POSTDATED, postdated );
177 }
178
179
180 public void setRenewableOk( boolean renewableOk )
181 {
182 setOrClear( KdcOptions.RENEWABLE_OK, renewableOk );
183 }
184
185
186 public void setRenewable( boolean renewable )
187 {
188 setOrClear( KdcOptions.RENEWABLE, renewable );
189 }
190
191
192 public KdcOptions getOptions()
193 {
194 return options;
195 }
196
197
198 public boolean isPreAuthEnabled()
199 {
200 return preAuthEnabled;
201 }
202
203
204 public void setPreAuthEnabled( boolean preAuthEnabled )
205 {
206 this.preAuthEnabled = preAuthEnabled;
207 }
208
209
210 public String getSName()
211 {
212 return KdcClientUtil.extractName( serverPrincipal );
213 }
214
215
216 public String getCName()
217 {
218 return KdcClientUtil.extractName( clientPrincipal );
219 }
220
221
222 public Set<EncryptionType> getETypes()
223 {
224 return eTypes;
225 }
226
227
228 public void setETypes( Set<EncryptionType> eTypes )
229 {
230 this.eTypes = eTypes;
231 }
232
233
234 private void setOrClear( int pos, boolean set )
235 {
236 if ( set )
237 {
238 options.setBit( pos );
239 }
240 else
241 {
242 options.clearBit( pos );
243 }
244 }
245 }