1 /*
2 * Licensed to The Apereo Foundation under one or more contributor license
3 * agreements. See the NOTICE file distributed with this work for additional
4 * information regarding copyright ownership.
5 *
6 *
7 * The Apereo Foundation licenses this file to you under the Educational
8 * Community License, Version 2.0 (the "License"); you may not use this file
9 * except in compliance with the License. You may obtain a copy of the License
10 * at:
11 *
12 * http://opensource.org/licenses/ecl2.txt
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17 * License for the specific language governing permissions and limitations under
18 * the License.
19 *
20 */
21
22 package org.opencastproject.security.api;
23
24 /**
25 * Provides access to the current user's username and roles, if any.
26 */
27 public interface SecurityService {
28
29 /**
30 * Gets the current user, or the local organization's anonymous user if the user has not been authenticated.
31 *
32 * @return the user
33 * @throws IllegalStateException
34 * if no organization is set in the security context
35 */
36 User getUser() throws IllegalStateException;
37
38 /**
39 * Gets the organization associated with the current thread context.
40 *
41 * @return the organization
42 */
43 Organization getOrganization();
44
45 /**
46 * Gets the current user's IP or null if unable to determine the User's IP.
47 *
48 * @return The current user's IP.
49 */
50 String getUserIP();
51
52 /**
53 * Sets the organization for the calling thread.
54 *
55 * @param organization
56 * the organization
57 */
58 void setOrganization(Organization organization);
59
60 /**
61 * Sets the current thread's user context to another user. This is useful when spawning new threads that must contain
62 * the parent thread's user context.
63 *
64 * @param user
65 * the user to set for the current user context
66 */
67 void setUser(User user);
68
69 /**
70 * Sets the current thread's user's IP address.
71 *
72 * @param userIP
73 * The IP address of the user.
74 */
75 void setUserIP(String userIP);
76
77 }