public class SecurityHelper extends Object implements org.pentaho.platform.api.engine.ISecurityHelper
Modifier | Constructor and Description |
---|---|
protected |
SecurityHelper()
Default constructor - protected so that it may be only constructed by a sub-class since this is a singleton
|
Modifier and Type | Method and Description |
---|---|
void |
becomeUser(String principalName)
Hi-jacks the system for the named user.
|
void |
becomeUser(String principalName,
org.pentaho.platform.api.engine.IParameterProvider paramProvider)
Hi-jacks the system for the named user.
|
org.springframework.security.core.Authentication |
createAuthentication(String principalName)
Utility method for hydrating a Spring Authentication object (Principal) given just a user name.
|
org.pentaho.platform.api.engine.IAclVoter |
getAclVoter()
Deprecated.
|
org.springframework.security.core.Authentication |
getAuthentication() |
org.springframework.security.core.Authentication |
getAuthentication(org.pentaho.platform.api.engine.IPentahoSession ignoredSession,
boolean ignoredAllowAnonymous)
Remove this method when data-access is JCR-branched
|
org.pentaho.platform.api.engine.IAuthorizationPolicy |
getAuthorizationPolicy() |
static org.pentaho.platform.api.engine.ISecurityHelper |
getInstance()
Returns the default instance, if the test instance is not null return the test instance
|
org.pentaho.platform.api.mt.ITenantedPrincipleNameResolver |
getTenantedUserNameUtils() |
org.springframework.security.core.userdetails.UserDetailsService |
getUserDetailsService() |
org.pentaho.platform.api.engine.IUserRoleListService |
getUserRoleListService() |
boolean |
hasAccess(org.pentaho.platform.api.engine.IAclHolder aHolder,
int actionOperation,
org.pentaho.platform.api.engine.IPentahoSession session)
Deprecated.
|
boolean |
isGranted(org.pentaho.platform.api.engine.IPentahoSession session,
org.springframework.security.core.GrantedAuthority role)
Utility method that communicates with the installed ACLVoter to determine whether a particular role is granted to
the specified user.
|
boolean |
isPentahoAdministrator(org.pentaho.platform.api.engine.IPentahoSession session)
Deprecated.
use SystemUtils.canAdminister() instead
|
<T> T |
runAsAnonymous(Callable<T> callable)
Utility method that allows you to run a block of code as the given user.
|
<T> T |
runAsSystem(Callable<T> callable)
Runs code as system with full privileges.
|
<T> T |
runAsUser(String principalName,
Callable<T> callable)
Utility method that allows you to run a block of code as the given user.
|
<T> T |
runAsUser(String principalName,
org.pentaho.platform.api.engine.IParameterProvider paramProvider,
Callable<T> callable) |
static void |
setMockInstance(org.pentaho.platform.api.engine.ISecurityHelper mockInstanceValue)
Set the mockInstance, this should only be used for testing
|
protected SecurityHelper()
public static org.pentaho.platform.api.engine.ISecurityHelper getInstance()
public static void setMockInstance(org.pentaho.platform.api.engine.ISecurityHelper mockInstanceValue)
mockInstanceValue
- the test implementation of SecurityHelperpublic void becomeUser(String principalName)
This will essentially create a session for this user, make that
session the current session, and add the Authentication objects to the session and Spring context holder. WARNING:
this method is irreversible!!! If you want execute a block of code as a surrogate user and have the orignal user
resume after it is complete, you want runAsUser(String, Callable)
.
This is for unit tests only.
becomeUser
in interface org.pentaho.platform.api.engine.ISecurityHelper
principalName
- the user to become in the systempublic void becomeUser(String principalName, org.pentaho.platform.api.engine.IParameterProvider paramProvider)
This is for unit tests only.
becomeUser
in interface org.pentaho.platform.api.engine.ISecurityHelper
public <T> T runAsUser(String principalName, Callable<T> callable) throws Exception
Callable
, then the system environment will return to the user
present prior to you calling this method.runAsUser
in interface org.pentaho.platform.api.engine.ISecurityHelper
T
- the return type of your operation, specify this type as T
principalName
- the user under whom you wish to run a section of codecallable
- Callable.call()
contains the code you wish to run as the given userCallable.call()
Exception
Callable}
public <T> T runAsUser(String principalName, org.pentaho.platform.api.engine.IParameterProvider paramProvider, Callable<T> callable) throws Exception
runAsUser
in interface org.pentaho.platform.api.engine.ISecurityHelper
Exception
public <T> T runAsAnonymous(Callable<T> callable) throws Exception
Callable
, then the system environment will return to the user
present prior to you calling this method.runAsAnonymous
in interface org.pentaho.platform.api.engine.ISecurityHelper
T
- the return type of your operation, specify this type as T
callable
- Callable.call()
contains the code you wish to run as the given userCallable.call()
Exception
Callable}
@Deprecated public boolean isPentahoAdministrator(org.pentaho.platform.api.engine.IPentahoSession session)
isPentahoAdministrator
in interface org.pentaho.platform.api.engine.ISecurityHelper
session
- The users IPentahoSession objectpublic boolean isGranted(org.pentaho.platform.api.engine.IPentahoSession session, org.springframework.security.core.GrantedAuthority role)
isGranted
in interface org.pentaho.platform.api.engine.ISecurityHelper
session
- The users' IPentahoSessionrole
- The role to look for@Deprecated public boolean hasAccess(org.pentaho.platform.api.engine.IAclHolder aHolder, int actionOperation, org.pentaho.platform.api.engine.IPentahoSession session)
hasAccess
in interface org.pentaho.platform.api.engine.ISecurityHelper
@Deprecated public org.pentaho.platform.api.engine.IAclVoter getAclVoter()
public org.springframework.security.core.Authentication createAuthentication(String principalName)
IUserRoleListService
will be consulted for the roles associated with this user.createAuthentication
in interface org.pentaho.platform.api.engine.ISecurityHelper
principalName
- the subject of this Authentication objectpublic org.springframework.security.core.Authentication getAuthentication()
getAuthentication
in interface org.pentaho.platform.api.engine.ISecurityHelper
public org.springframework.security.core.Authentication getAuthentication(org.pentaho.platform.api.engine.IPentahoSession ignoredSession, boolean ignoredAllowAnonymous)
getAuthentication
in interface org.pentaho.platform.api.engine.ISecurityHelper
ignoredSession
- ignoredAllowAnonymous
- public <T> T runAsSystem(Callable<T> callable) throws Exception
runAsSystem
in interface org.pentaho.platform.api.engine.ISecurityHelper
Exception
public org.pentaho.platform.api.engine.IAuthorizationPolicy getAuthorizationPolicy()
public org.pentaho.platform.api.mt.ITenantedPrincipleNameResolver getTenantedUserNameUtils()
public org.springframework.security.core.userdetails.UserDetailsService getUserDetailsService()
public org.pentaho.platform.api.engine.IUserRoleListService getUserRoleListService()
Copyright © 2019 Hitachi Vantara. All rights reserved.