Search in sources :

Example 11 with ITenantedPrincipleNameResolver

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;
}
Also used : ITenant(org.pentaho.platform.api.mt.ITenant) ITenantedPrincipleNameResolver(org.pentaho.platform.api.mt.ITenantedPrincipleNameResolver)

Example 12 with ITenantedPrincipleNameResolver

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;
}
Also used : ITenant(org.pentaho.platform.api.mt.ITenant) ITenantedPrincipleNameResolver(org.pentaho.platform.api.mt.ITenantedPrincipleNameResolver)

Example 13 with ITenantedPrincipleNameResolver

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;
}
Also used : ITenant(org.pentaho.platform.api.mt.ITenant) ITenantedPrincipleNameResolver(org.pentaho.platform.api.mt.ITenantedPrincipleNameResolver)

Example 14 with ITenantedPrincipleNameResolver

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);
}
Also used : Locale(java.util.Locale) ITenant(org.pentaho.platform.api.mt.ITenant) Authentication(org.springframework.security.core.Authentication) UserSession(org.pentaho.platform.engine.core.system.UserSession) ITenantedPrincipleNameResolver(org.pentaho.platform.api.mt.ITenantedPrincipleNameResolver)

Aggregations

ITenantedPrincipleNameResolver (org.pentaho.platform.api.mt.ITenantedPrincipleNameResolver)14 ITenant (org.pentaho.platform.api.mt.ITenant)7 LRUMap (org.apache.commons.collections.map.LRUMap)2 User (org.apache.jackrabbit.api.security.user.User)2 Test (org.junit.Test)2 IPentahoUser (org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)2 Locale (java.util.Locale)1 Matchers.anyString (org.mockito.Matchers.anyString)1 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)1 Tenant (org.pentaho.platform.core.mt.Tenant)1 UserSession (org.pentaho.platform.engine.core.system.UserSession)1 Authentication (org.springframework.security.core.Authentication)1