SecurityHelper implements ISecurityHelper { @Override public <T> T runAsUser( final String principalName, final Callable<T> callable ) throws Exception { return runAsUser( principalName, null, callable ); } protected  SecurityHelper(); static ISecurityHelper getInstance(); static void setMockInstance( ISecurityHelper mockInstanceValue ); @Override void becomeUser( final String principalName ); @Override void becomeUser( final String principalName, final IParameterProvider paramProvider ); @Override T runAsUser( final String principalName, final Callable<T> callable ); @Override T runAsUser( final String principalName, final IParameterProvider paramProvider, final Callable<T> callable ); @Override T runAsAnonymous( final Callable<T> callable ); @Override @Deprecated boolean isPentahoAdministrator( final IPentahoSession session ); @Override boolean isGranted( final IPentahoSession session, final GrantedAuthority role ); @Deprecated boolean hasAccess( IAclHolder aHolder, int actionOperation, IPentahoSession session ); @Deprecated IAclVoter getAclVoter(); @Override Authentication createAuthentication( String principalName ); @Override Authentication getAuthentication(); @Override Authentication getAuthentication( IPentahoSession ignoredSession, boolean ignoredAllowAnonymous ); T runAsSystem( final Callable<T> callable ); IAuthorizationPolicy getAuthorizationPolicy(); ITenantedPrincipleNameResolver getTenantedUserNameUtils(); UserDetailsService getUserDetailsService(); IUserRoleListService getUserRoleListService();  }
@Test @SuppressWarnings( "unchecked" ) public void runAsUserTest() throws Exception { Callable<String> callable = (Callable<String>) mock( Callable.class ); when( callable.call() ).thenReturn( CALLABLE_RETURNED_VALUE_OK ); String runningResult = getAuthorizedSecurityHelper().runAsUser( DEF_USERNAME, callable ); assertEquals( CALLABLE_RETURNED_VALUE_OK, runningResult ); }