use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.
the class DirectoryResourceIT method login.
/**
* Logs in with given username.
*
* @param username username of user
* @param tenant tenant to which this user belongs
* @tenantAdmin true to add the tenant admin authority to the user's roles
*/
protected void login(final String username, final ITenant tenant, final boolean tenantAdmin) {
StandaloneSession pentahoSession = new StandaloneSession(username);
pentahoSession.setAuthenticated(username);
pentahoSession.setAttribute(IPentahoSession.TENANT_ID_KEY, tenant.getId());
final String password = "password";
List<GrantedAuthority> authList = new ArrayList<GrantedAuthority>();
authList.add(new SimpleGrantedAuthority(authenticatedAuthorityName));
if (tenantAdmin) {
authList.add(new SimpleGrantedAuthority(adminAuthorityName));
}
UserDetails userDetails = new User(username, password, true, true, true, true, authList);
Authentication auth = new UsernamePasswordAuthenticationToken(userDetails, password, authList);
PentahoSessionHolder.setSession(pentahoSession);
// this line necessary for Spring Security's MethodSecurityInterceptor
SecurityContextHolder.getContext().setAuthentication(auth);
}
use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.
the class DirectoryResourceIT method login.
/**
* Logs in with given username.
*
* @param username username of user
* @param tenant tenant to which this user belongs
* @tenantAdmin true to add the tenant admin authority to the user's roles
*/
protected void login(final String username, final ITenant tenant, String[] roles) {
StandaloneSession pentahoSession = new StandaloneSession(username);
pentahoSession.setAuthenticated(tenant.getId(), username);
PentahoSessionHolder.setSession(pentahoSession);
pentahoSession.setAttribute(IPentahoSession.TENANT_ID_KEY, tenant.getId());
final String password = "password";
List<GrantedAuthority> authList = new ArrayList<GrantedAuthority>();
for (String roleName : roles) {
authList.add(new SimpleGrantedAuthority(roleName));
}
UserDetails userDetails = new User(username, password, true, true, true, true, authList);
Authentication auth = new UsernamePasswordAuthenticationToken(userDetails, password, authList);
PentahoSessionHolder.setSession(pentahoSession);
// this line necessary for Spring Security's MethodSecurityInterceptor
SecurityContextHolder.getContext().setAuthentication(auth);
}
use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.
the class DirectoryResourceIT method loginAsRepositoryAdmin.
protected void loginAsRepositoryAdmin() {
StandaloneSession pentahoSession = new StandaloneSession(repositoryAdminUsername);
pentahoSession.setAuthenticated(repositoryAdminUsername);
final List<GrantedAuthority> repositoryAdminAuthorities = Arrays.asList(new GrantedAuthority[] { new SimpleGrantedAuthority(sysAdminAuthorityName) });
final String password = "ignored";
UserDetails repositoryAdminUserDetails = new User(repositoryAdminUsername, password, true, true, true, true, repositoryAdminAuthorities);
Authentication repositoryAdminAuthentication = new UsernamePasswordAuthenticationToken(repositoryAdminUserDetails, password, repositoryAdminAuthorities);
PentahoSessionHolder.setSession(pentahoSession);
// this line necessary for Spring Security's MethodSecurityInterceptor
SecurityContextHolder.getContext().setAuthentication(repositoryAdminAuthentication);
}
use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.
the class FileResourceIT method login.
/**
* Logs in with given username.
*
* @param username username of user
* @param tenant tenant to which this user belongs
* @tenantAdmin true to add the tenant admin authority to the user's roles
*/
protected void login(final String username, final ITenant tenant, String[] roles) {
StandaloneSession pentahoSession = new StandaloneSession(username);
pentahoSession.setAuthenticated(tenant.getId(), username);
PentahoSessionHolder.setSession(pentahoSession);
pentahoSession.setAttribute(IPentahoSession.TENANT_ID_KEY, tenant.getId());
final String password = "password";
List<GrantedAuthority> authList = new ArrayList<GrantedAuthority>();
for (String roleName : roles) {
authList.add(new SimpleGrantedAuthority(roleName));
}
UserDetails userDetails = new User(username, password, true, true, true, true, authList);
Authentication auth = new UsernamePasswordAuthenticationToken(userDetails, password, authList);
PentahoSessionHolder.setSession(pentahoSession);
// this line necessary for Spring Security's MethodSecurityInterceptor
SecurityContextHolder.getContext().setAuthentication(auth);
}
use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.
the class FileResourceIT method loginAsRepositoryAdmin.
protected void loginAsRepositoryAdmin() {
StandaloneSession pentahoSession = new StandaloneSession(repositoryAdminUsername);
pentahoSession.setAuthenticated(repositoryAdminUsername);
final List<GrantedAuthority> repositoryAdminAuthorities = Arrays.asList(new GrantedAuthority[] { new SimpleGrantedAuthority(sysAdminAuthorityName) });
final String password = "ignored";
UserDetails repositoryAdminUserDetails = new User(repositoryAdminUsername, password, true, true, true, true, repositoryAdminAuthorities);
Authentication repositoryAdminAuthentication = new UsernamePasswordAuthenticationToken(repositoryAdminUserDetails, password, repositoryAdminAuthorities);
PentahoSessionHolder.setSession(pentahoSession);
// this line necessary for Spring Security's MethodSecurityInterceptor
SecurityContextHolder.getContext().setAuthentication(repositoryAdminAuthentication);
}
Aggregations