public final class SecurityUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
PROPERTY_KEY_SYS_USER
The name of the key used to store the name of the system user in the global config.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
checkAgentAccess(SecurityService securityService,
String agentId)
Check if the current user has access to the capture agent with the given id.
|
static User |
createAnonymousUser(Organization org)
Create the global anonymous user with the given organization.
|
static User |
createSystemUser(org.osgi.service.component.ComponentContext cc,
Organization org)
Create a system user for the given organization with global admin role.
|
static User |
createSystemUser(String systemUserName,
Organization org)
Create a system user for the given organization with global and organization local admin role.
|
static String |
getCaptureAgentRole(String agentId)
Get the role name of the role required to access the capture agent with the given agent id.
|
static Option<Organization> |
getOrganization(OrganizationDirectoryService orgDir,
String orgId)
Get the organization
orgId. |
static String |
getSystemUserName(org.osgi.service.component.ComponentContext cc)
Fetch the system user name from the configuration.
|
static Option<Tuple<User,Organization>> |
getUserAndOrganization(SecurityService sec,
OrganizationDirectoryService orgDir,
String orgId,
UserDirectoryService userDir,
String userId)
Get a user and an organization.
|
static Option<User> |
getUserOfOrganization(SecurityService sec,
OrganizationDirectoryService orgDir,
String orgId,
UserDirectoryService userDir,
String userId)
Get a user of a certain organization by its ID.
|
static Tuple<String,Integer> |
hostAndPort(URL url)
Extract hostname and port number from a URL.
|
static void |
runAs(SecurityService sec,
Organization org,
User user,
Runnable fn)
Run function
f in the context described by the given organization and user. |
public static final String PROPERTY_KEY_SYS_USER
public static void runAs(SecurityService sec, Organization org, User user, Runnable fn)
f in the context described by the given organization and user.sec - Security service to use for getting dataorg - Organization to switch touser - User to switch tofn - Function to executepublic static User createSystemUser(String systemUserName, Organization org)
systemUserName from the global config where it is stored under PROPERTY_KEY_SYS_USER. In an
OSGi environment this is typically done calling
componentContext.getBundleContext().getProperty(PROPERTY_KEY_SYS_USER).public static User createAnonymousUser(Organization org)
org - the organizationpublic static User createSystemUser(org.osgi.service.component.ComponentContext cc, Organization org)
public static String getSystemUserName(org.osgi.service.component.ComponentContext cc)
PROPERTY_KEY_SYS_USERpublic static Option<Organization> getOrganization(OrganizationDirectoryService orgDir, String orgId)
orgId.public static Option<User> getUserOfOrganization(SecurityService sec, OrganizationDirectoryService orgDir, String orgId, UserDirectoryService userDir, String userId)
public static Option<Tuple<User,Organization>> getUserAndOrganization(SecurityService sec, OrganizationDirectoryService orgDir, String orgId, UserDirectoryService userDir, String userId)
public static Tuple<String,Integer> hostAndPort(URL url)
public static void checkAgentAccess(SecurityService securityService, String agentId) throws UnauthorizedException
agentId - The agent id to check.UnauthorizedException - If the user doesn't have access.Copyright © 2009–2021 Opencast Project. All rights reserved.