use of org.pentaho.platform.api.mt.ITenantedPrincipleNameResolver in project pentaho-kettle by pentaho.
the class PurRepositoryIT method getPrincipalName.
protected String getPrincipalName(String principalId, boolean isUser) {
String principalName = null;
ITenantedPrincipleNameResolver nameUtils = isUser ? userNameUtils : roleNameUtils;
if (nameUtils != null) {
principalName = nameUtils.getPrincipleName(principalId);
}
return principalName;
}
use of org.pentaho.platform.api.mt.ITenantedPrincipleNameResolver in project pentaho-kettle by pentaho.
the class UIEERepositoryDirectoryIT method getTenant.
private 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 TenantUtils method getCurrentTenant.
/**
* Returns the tenant ID of the current user.
*/
public static ITenant getCurrentTenant() {
IPentahoSession pentahoSession = PentahoSessionHolder.getSession();
if (pentahoSession == null) {
throw new IllegalStateException();
}
String tenantId = (String) pentahoSession.getAttribute(IPentahoSession.TENANT_ID_KEY);
if (tenantId == null) {
ITenantedPrincipleNameResolver tenantedUserNameUtils = PentahoSystem.get(ITenantedPrincipleNameResolver.class, "tenantedUserNameUtils", pentahoSession);
if (tenantedUserNameUtils != null) {
ITenant tenant = tenantedUserNameUtils.getTenant(pentahoSession.getId());
pentahoSession.setAttribute(IPentahoSession.TENANT_ID_KEY, tenant.getId());
return new Tenant(tenant.getId(), true);
}
}
return new Tenant(tenantId, true);
}
use of org.pentaho.platform.api.mt.ITenantedPrincipleNameResolver in project pentaho-platform by pentaho.
the class JcrTenantUtils method getPrincipalName.
public static String getPrincipalName(String principalId, boolean isUser) {
String principalName = null;
ITenantedPrincipleNameResolver nameUtils = isUser ? getUserNameUtils() : getRoleNameUtils();
if (nameUtils != null) {
principalName = nameUtils.getPrincipleName(principalId);
}
return principalName;
}
use of org.pentaho.platform.api.mt.ITenantedPrincipleNameResolver in project pentaho-platform by pentaho.
the class AbstractJcrBackedUserRoleDaoTest method testConvertToPentahoUserEnableCache.
@Test
public void testConvertToPentahoUserEnableCache() throws RepositoryException {
AbstractJcrBackedUserRoleDao abstractJcrBackedUserRoleDaoMock = mock(AbstractJcrBackedUserRoleDao.class);
doCallRealMethod().when(abstractJcrBackedUserRoleDaoMock).convertToPentahoUser(nullable(User.class));
ITenantedPrincipleNameResolver resolverMock = mock(ITenantedPrincipleNameResolver.class);
when(abstractJcrBackedUserRoleDaoMock.getTenantedUserNameUtils()).thenReturn(resolverMock);
when(abstractJcrBackedUserRoleDaoMock.isUseJackrabbitUserCache()).thenReturn(true);
// Cache mocking
LRUMap cacheMock = mock(LRUMap.class);
when(abstractJcrBackedUserRoleDaoMock.getUserCache()).thenReturn(cacheMock);
User userMock = mock(User.class);
abstractJcrBackedUserRoleDaoMock.convertToPentahoUser(userMock);
verify(cacheMock).put(any(), any());
}
Aggregations