1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package no.feide.moria.store;
22
23 import java.util.HashMap;
24 import java.util.Properties;
25
26 /***
27 * The store manager's main functionality is to handle tickets. The
28 * interface makes it possible to create tickets and store them and
29 * their associated data. The interface also has support for removal
30 * of expired tickets.
31 *
32 * @author Bjørn Ola Smievoll <b.o@smievoll.no>
33 * @version $Revision: 1.18 $
34 */
35 public interface MoriaStore {
36
37 /***
38 * Sets the configuration of the store.
39 *
40 * @param properties
41 * Object containing the necessary attributes for store configuration.
42 * @throws MoriaStoreConfigurationException
43 * If the store cannot be started with the given configuration.
44 * @throws IllegalArgumentException
45 * If properties is null.
46 */
47 void setConfig(Properties properties)
48 throws MoriaStoreConfigurationException;
49
50 /***
51 * Stops this instance of the store.
52 */
53 void stop();
54
55 /***
56 * Creates an authentication attempt based on a service request.
57 *
58 * @param requestAttributes
59 * The user attributes the requesting service asks for.
60 * @param responseURLPrefix
61 * The forward part of the url the client is to be redirected to.
62 * @param responseURLPostfix
63 * The end part of the url the client is to be redirected to.
64 * @param forceInteractiveAuthentication
65 * If the user should be forced to login interactively. I.e. disable
66 * support for single sign-on.
67 * @param servicePrincipal
68 * The id of the service doing the request.
69 * @return A login ticket identifying the authentication attempt.
70 * @throws MoriaStoreException
71 * If the operation fails.
72 * @throws IllegalArgumentException
73 * If any of the arguments are null, and if responseURLPrefix or servicePrincipal are zero length.
74 */
75 String createAuthnAttempt(final String[] requestAttributes, final String responseURLPrefix, final String responseURLPostfix,
76 final boolean forceInteractiveAuthentication, final String servicePrincipal)
77 throws MoriaStoreException;
78
79 /***
80 * Gets the authentication attempt associated with the ticket given as argument.
81 *
82 * @param ticketId
83 * the ticket from the incoming client request (must be LOGIN or SERVICE)
84 * @param keep
85 * if true the authnAttempt and ticket will be kept in the store after this operation
86 * @param servicePrincipal
87 * the principal of the service requesting the operation (null if login ticket is supplied)
88 * @return the MoriaAuthnAttempt associated with the ticket
89 * @throws InvalidTicketException
90 * if the incoming ticket is found to be invalid
91 * @throws NonExistentTicketException
92 * If ticket does not exist
93 * @throws MoriaStoreException
94 * If the operation fails
95 * @throws IllegalArgumentException
96 * If ticketId is null or zero length and if no servicePrincipal is
97 * supplied with a service ticket
98 */
99 MoriaAuthnAttempt getAuthnAttempt(final String ticketId, final boolean keep, final String servicePrincipal)
100 throws InvalidTicketException, NonExistentTicketException, MoriaStoreException;
101
102 /***
103 * Creates a new CachedUserData object in the underlying store and associates it with an SSO
104 * ticket which is returned.
105 *
106 * @param attributes
107 * The attribute map to be cached.
108 * @param userorg
109 * The userorg that is to be associated with the ticket.
110 * @return The SSO ticket that identifies the cached user data.
111 * @throws MoriaStoreException
112 * If the operation fails.
113 * @throws IllegalArgumentException
114 * If attributes is null, or
115 * userorg is null or an empty string.
116 */
117 String cacheUserData(final HashMap attributes, final String userorg)
118 throws MoriaStoreException;
119
120 /***
121 * Returns the userdata associated with the incoming ticket, which must be either a
122 * proxy ticket, an SSO ticket or ticket granting ticket.
123 *
124 * @param proxyTicketId
125 * A ticket to identify a userdata object (SSO, TGT or PROXY).
126 * @param servicePrincipal
127 * The name of the service requesting the data,
128 * @return A clone of the object containing the userdata.
129 * @throws InvalidTicketException
130 * If the incoming ticket is not of the correct type or
131 * has an invalid principal.
132 * @throws NonExistentTicketException
133 * If ticket does not exist.
134 * @throws MoriaStoreException
135 * If the operation fails.
136 * @throws IllegalArgumentException
137 * If ticketId is null or zero length, or SSO ticket principal
138 * is null or zero length.
139 */
140 CachedUserData getUserData(final String proxyTicketId, final String servicePrincipal)
141 throws InvalidTicketException, NonExistentTicketException, MoriaStoreException;
142
143 /***
144 * Creates a service ticket that the service will use when requesting user attributes after a
145 * successful authentication.
146 *
147 * @param loginTicketId
148 * A login ticket associated with an authentication attempt.
149 * @return A service ticket associated with the authentication attempt object.
150 * @throws InvalidTicketException
151 * If the supplied ticket is not a login ticket.
152 * @throws NonExistentTicketException
153 * If ticket does not exist.
154 * @throws MoriaStoreException
155 * If the operation fails.
156 * @throws IllegalArgumentException
157 * If loginTicketId is null or zero length.
158 */
159 String createServiceTicket(final String loginTicketId)
160 throws InvalidTicketException, NonExistentTicketException, MoriaStoreException;
161
162 /***
163 * Creates a new ticket granting ticket, using an sso ticket.
164 *
165 * @param ssoTicketId
166 * An sso ticket that is already associated with a cached userdata object.
167 * @param targetServicePrincipal
168 * The id of the service that will use the TGT.
169 * @return A ticket-granting ticket that the requesting service may use for later proxy
170 * authentication.
171 * @throws InvalidTicketException
172 * If the argument ticket is not an SSO ticket or has an invalid principal.
173 * @throws NonExistentTicketException
174 * If ticket does not exist.
175 * @throws MoriaStoreException
176 * If the operation fails.
177 * @throws IllegalArgumentException
178 * If any of the arguments are null or zero length.
179 */
180 String createTicketGrantingTicket(final String ssoTicketId, final String targetServicePrincipal)
181 throws InvalidTicketException, NonExistentTicketException, MoriaStoreException;
182
183 /***
184 * Creates a new proxy ticket from a TGT and associates the new ticket with the same user data as
185 * the TGT.
186 *
187 * @param tgTicketId
188 * A TGT issued earlier to a service.
189 * @param servicePrincipal
190 * The id of the service making the request.
191 * @param targetServicePrincipal
192 * The id of the service that will use the proxy ticket.
193 * @return Proxy ticket that may be used by the requesting service.
194 * @throws InvalidTicketException
195 * If the incoming ticket is not a TGT or has an invalid principal.
196 * @throws NonExistentTicketException
197 * If ticket does not exist.
198 * @throws MoriaStoreException
199 * If the operation fails.
200 * @throws IllegalArgumentException
201 * If any of the arguments are null or zero length.
202 */
203 String createProxyTicket(final String tgTicketId, final String servicePrincipal, final String targetServicePrincipal)
204 throws InvalidTicketException, NonExistentTicketException, MoriaStoreException;
205
206 /***
207 * Sets transient attributes stored with authentication attempt.
208 *
209 * @param loginTicketId
210 * Ticket that identifies the AuthnAttempt that the attributes will be
211 * associated with.
212 * @param transientAttributes
213 * Attributes to store with the AuthnAttempt.
214 * @throws InvalidTicketException
215 * If ticket is found invalid.
216 * @throws NonExistentTicketException
217 * If ticket does not exist.
218 * @throws MoriaStoreException
219 * If the operation fails.
220 * @throws IllegalArgumentException
221 * If loginTicketId is null or zero length, or transientAttributes is null.
222 */
223 void setTransientAttributes(final String loginTicketId, final HashMap transientAttributes)
224 throws InvalidTicketException, NonExistentTicketException, MoriaStoreException;
225
226 /***
227 * Sets transient attributes stored with authentication attempt,
228 * copied from a cached user data object.
229 *
230 * @param loginTicketId
231 * Ticket that identifies the AuthnAttempt that the attributes will be
232 * associated with.
233 * @param ssoTicketId
234 * Ticket associated with a set of cached user data.
235 * @param ssoEnabledAttributeNames
236 * The names of those attributes which should be stored with the
237 * authentication attempt; should include only those attributes
238 * the service is allowed to use in an SSO context.
239 * @throws InvalidTicketException
240 * If either ticket is found invalid.
241 * @throws NonExistentTicketException
242 * If either ticket does not exist.
243 * @throws MoriaStoreException
244 * If the operation fails.
245 * @throws IllegalArgumentException
246 * If either ticket id is null or zero length.
247 */
248 void setTransientSSOAttributes(final String loginTicketId, final String ssoTicketId, final String[] ssoEnabledAttributeNames)
249 throws InvalidTicketException, NonExistentTicketException, MoriaStoreException;
250
251 /***
252 * Removes an SSO ticket from the store.
253 *
254 * @param ssoTicketId
255 * the ticketId of the ticket to remove
256 * @throws NonExistentTicketException
257 * If ticket does not exist
258 * @throws MoriaStoreException
259 * If the operation fails
260 * @throws IllegalArgumentException
261 * If ssoTicketId is null or zero length
262 */
263 void removeSSOTicket(final String ssoTicketId)
264 throws NonExistentTicketException, MoriaStoreException;
265
266 /***
267 * Returns the service principal for the ticket.
268 *
269 * @param ticketId The ticket id.
270 * @param ticketType The ticket type.
271 * @return Service principal.
272 * @throws InvalidTicketException
273 * If the ticket is invalid.
274 * @throws NonExistentTicketException
275 * If ticket does not exist.
276 * @throws MoriaStoreException
277 * If the operation fails.
278 * @throws IllegalArgumentException
279 * If ticketId is null or zero length.
280 */
281 String getTicketServicePrincipal(final String ticketId, MoriaTicketType ticketType)
282 throws InvalidTicketException, NonExistentTicketException, MoriaStoreException;
283
284 /***
285 * Sets the userorg of a ticket.
286 *
287 * @param ticketId The ticket id.
288 * @param ticketType The ticket type.
289 * @param userorg The userorg of the user creating the ticket.
290 * @throws InvalidTicketException
291 * if the ticket is invalid.
292 * @throws NonExistentTicketException
293 * If ticket does not exist.
294 * @throws MoriaStoreException
295 * If the operation fails.
296 * @throws IllegalArgumentException
297 * If ticketId is null or zero length.
298 */
299 void setTicketUserorg(final String ticketId, MoriaTicketType ticketType, String userorg)
300 throws InvalidTicketException, NonExistentTicketException, MoriaStoreException;
301
302 /***
303 * Gets the userorg of a ticket.
304 *
305 * @param ticketId the ticket id.
306 * @param ticketType the ticket type.
307 * @return the organization of the user creating the ticket, or null if not set.
308 * @throws InvalidTicketException
309 * If the ticket is invalid.
310 * @throws NonExistentTicketException
311 * If ticket does not exist.
312 * @throws MoriaStoreException
313 * If the operation fails.
314 * @throws IllegalArgumentException
315 * If ticketId is null or zero length.
316 */
317 String getTicketUserorg(final String ticketId, MoriaTicketType ticketType)
318 throws InvalidTicketException, NonExistentTicketException, MoriaStoreException;
319
320 }