use of org.pentaho.platform.api.mt.ITenantedPrincipleNameResolver in project pentaho-platform by pentaho.
the class MockUserRoleDao method getTenant.
protected ITenant getTenant(String principalId, boolean isUser) {
ITenant tenant = null;
ITenantedPrincipleNameResolver nameUtils = isUser ? userNameResolver : roleNameResolver;
if (nameUtils != null) {
tenant = nameUtils.getTenant(principalId);
}
if (tenant == null || tenant.getId() == null) {
tenant = getCurrentTenant();
}
return tenant;
}
use of org.pentaho.platform.api.mt.ITenantedPrincipleNameResolver in project pentaho-platform by pentaho.
the class JcrTenantUtils method getTenant.
public static ITenant getTenant(String principalId, boolean isUser) {
ITenant tenant = null;
ITenantedPrincipleNameResolver nameUtils = isUser ? getUserNameUtils() : getRoleNameUtils();
if (nameUtils != null) {
tenant = nameUtils.getTenant(principalId);
}
if (tenant == null || tenant.getId() == null || !tenant.getId().startsWith("/")) {
tenant = getCurrentTenant();
}
if (tenant == null || tenant.getId() == null) {
tenant = getDefaultTenant();
}
return tenant;
}
use of org.pentaho.platform.api.mt.ITenantedPrincipleNameResolver in project pentaho-platform by pentaho.
the class DefaultUnifiedRepositoryBase method getTenant.
protected ITenant getTenant(String principalId, boolean isUser) {
ITenant tenant = null;
ITenantedPrincipleNameResolver nameUtils = isUser ? userNameUtils : roleNameUtils;
if (nameUtils != null) {
tenant = nameUtils.getTenant(principalId);
}
if (tenant == null || tenant.getId() == null) {
tenant = getCurrentTenant();
}
return tenant;
}
use of org.pentaho.platform.api.mt.ITenantedPrincipleNameResolver in project pentaho-platform by pentaho.
the class ProxyTrustingFilter method becomeUser.
// cloned from SecurityHelper and adapted to add a default location to the session
protected void becomeUser(final String principalName) {
UserSession session;
Locale locale = Locale.getDefault();
ITenantedPrincipleNameResolver tenantedUserNameUtils = PentahoSystem.get(ITenantedPrincipleNameResolver.class, "tenantedUserNameUtils", null);
if (tenantedUserNameUtils != null) {
session = new UserSession(principalName, locale, false, null);
ITenant tenant = tenantedUserNameUtils.getTenant(principalName);
session.setAttribute(IPentahoSession.TENANT_ID_KEY, tenant.getId());
session.setAuthenticated(tenant.getId(), principalName);
} else {
session = new UserSession(principalName, locale, false, null);
session.setAuthenticated(principalName);
}
PentahoSessionHolder.setSession(session);
Authentication auth = SecurityHelper.getInstance().createAuthentication(principalName);
SecurityContextHolder.getContext().setAuthentication(auth);
PentahoSystem.sessionStartup(PentahoSessionHolder.getSession(), null);
}
Aggregations