Search in sources :

Example 1 with NotFoundException

use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.

the class MockUserRoleDao method setRoleDescription.

public void setRoleDescription(ITenant tenant, String roleName, String description) throws NotFoundException, UncategorizedUserRoleDaoException {
    IPentahoRole role = getRole(tenant, roleName);
    if (role == null) {
        throw new NotFoundException(roleName);
    }
    role.setDescription(description);
}
Also used : NotFoundException(org.pentaho.platform.api.engine.security.userroledao.NotFoundException) IPentahoRole(org.pentaho.platform.api.engine.security.userroledao.IPentahoRole)

Example 2 with NotFoundException

use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.

the class MockUserRoleDao method setUserDescription.

public void setUserDescription(ITenant tenant, String userName, String description) throws NotFoundException, UncategorizedUserRoleDaoException {
    IPentahoUser user = getUser(tenant, userName);
    if (user == null) {
        throw new NotFoundException(userName);
    }
    user.setDescription(description);
}
Also used : NotFoundException(org.pentaho.platform.api.engine.security.userroledao.NotFoundException) IPentahoUser(org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)

Example 3 with NotFoundException

use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.

the class MockUserRoleDao method setPassword.

public void setPassword(ITenant tenant, String userName, String password) throws NotFoundException, UncategorizedUserRoleDaoException {
    IPentahoUser user = getUser(tenant, userName);
    if (user == null) {
        throw new NotFoundException(userName);
    }
    user.setPassword(password);
}
Also used : NotFoundException(org.pentaho.platform.api.engine.security.userroledao.NotFoundException) IPentahoUser(org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)

Example 4 with NotFoundException

use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.

the class UserRoleDaoEncodeIT method testUpdateUser.

@Test
public void testUpdateUser() throws Exception {
    loginAsRepositoryAdmin();
    systemTenant = tenantManager.createTenant(null, ServerRepositoryPaths.getPentahoRootFolderName(), adminRoleName, authenticatedRoleName, "Anonymous");
    userRoleDaoProxy.createUser(systemTenant, sysAdminUserName, "password", "", new String[] { adminRoleName });
    login(sysAdminUserName, systemTenant, new String[] { adminRoleName, authenticatedRoleName });
    mainTenant_1 = tenantManager.createTenant(systemTenant, MAIN_TENANT_1, adminRoleName, authenticatedRoleName, "Anonymous");
    userRoleDaoProxy.createUser(mainTenant_1, "admin", "password", "", new String[] { adminRoleName });
    mainTenant_2 = tenantManager.createTenant(systemTenant, MAIN_TENANT_2, adminRoleName, authenticatedRoleName, "Anonymous");
    userRoleDaoProxy.createUser(mainTenant_2, "admin", "password", "", new String[] { adminRoleName });
    login("admin", mainTenant_1, new String[] { adminRoleName, authenticatedRoleName });
    IPentahoUser pentahoUser = userRoleDaoProxy.createUser(mainTenant_1, USER_5, PASSWORD_5, USER_DESCRIPTION_5, null);
    pentahoUser = userRoleDaoProxy.getUser(mainTenant_1, USER_5);
    assertEquals(pentahoUser.getDescription(), USER_DESCRIPTION_5);
    String changedDescription1 = USER_DESCRIPTION_5 + "change1";
    userRoleDaoProxy.setUserDescription(mainTenant_1, USER_5, changedDescription1);
    pentahoUser = userRoleDaoProxy.getUser(null, USER_5 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER + mainTenant_1.getRootFolderAbsolutePath());
    assertEquals(changedDescription1, pentahoUser.getDescription());
    String changedDescription2 = USER_DESCRIPTION_5 + "change2";
    userRoleDaoProxy.setUserDescription(null, USER_5 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER + mainTenant_1.getRootFolderAbsolutePath(), changedDescription2);
    pentahoUser = userRoleDaoProxy.getUser(mainTenant_1, USER_5);
    assertEquals(changedDescription2, pentahoUser.getDescription());
    userRoleDaoProxy.setUserDescription(null, USER_5 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER + mainTenant_1.getRootFolderAbsolutePath(), null);
    pentahoUser = userRoleDaoProxy.getUser(mainTenant_1, USER_5);
    assertNull(pentahoUser.getDescription());
    try {
        userRoleDaoProxy.setUserDescription(null, null, changedDescription2);
        fail("Exception not thrown");
    } catch (Exception ex) {
    // Expected exception
    }
    try {
        userRoleDaoProxy.setUserDescription(null, USER_5, changedDescription2);
    } catch (Exception ex) {
    // Expected exception
    }
    try {
        userRoleDaoProxy.setUserDescription(mainTenant_1, UNKNOWN_USER, changedDescription2);
        fail("Exception not thrown");
    } catch (NotFoundException ex) {
    // Expected exception
    }
    logout();
    login("admin", mainTenant_2, new String[] { adminRoleName, authenticatedRoleName });
    try {
        changedDescription1 = USER_DESCRIPTION_5 + "change1";
        userRoleDaoProxy.setUserDescription(mainTenant_1, USER_5, changedDescription1);
        fail("Exception not thrown");
    } catch (Throwable th) {
        assertNotNull(th);
    }
    logout();
}
Also used : NotFoundException(org.pentaho.platform.api.engine.security.userroledao.NotFoundException) IPentahoUser(org.pentaho.platform.api.engine.security.userroledao.IPentahoUser) AlreadyExistsException(org.pentaho.platform.api.engine.security.userroledao.AlreadyExistsException) NotFoundException(org.pentaho.platform.api.engine.security.userroledao.NotFoundException) AccessControlException(javax.jcr.security.AccessControlException) RepositoryException(javax.jcr.RepositoryException) BeansException(org.springframework.beans.BeansException) IOException(java.io.IOException) Test(org.junit.Test)

Example 5 with NotFoundException

use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.

the class UserRoleDaoIT method testUpdateRole.

@Test
public void testUpdateRole() throws Exception {
    loginAsRepositoryAdmin();
    systemTenant = tenantManager.createTenant(null, ServerRepositoryPaths.getPentahoRootFolderName(), adminRoleName, authenticatedRoleName, "Anonymous");
    userRoleDaoProxy.createUser(systemTenant, sysAdminUserName, "password", "", new String[] { adminRoleName });
    login(sysAdminUserName, systemTenant, new String[] { adminRoleName, authenticatedRoleName });
    mainTenant_1 = tenantManager.createTenant(systemTenant, MAIN_TENANT_1, adminRoleName, authenticatedRoleName, "Anonymous");
    userRoleDaoProxy.createUser(mainTenant_1, "admin", "password", "", new String[] { adminRoleName });
    mainTenant_2 = tenantManager.createTenant(systemTenant, MAIN_TENANT_2, adminRoleName, authenticatedRoleName, "Anonymous");
    userRoleDaoProxy.createUser(mainTenant_2, "admin", "password", "", new String[] { adminRoleName });
    login("admin", mainTenant_1, new String[] { adminRoleName, authenticatedRoleName });
    IPentahoRole pentahoRole = userRoleDaoProxy.createRole(mainTenant_1, ROLE_5, ROLE_DESCRIPTION_5, null);
    pentahoRole = userRoleDaoProxy.getRole(mainTenant_1, ROLE_5);
    assertEquals(pentahoRole.getDescription(), ROLE_DESCRIPTION_5);
    String changedDescription1 = ROLE_DESCRIPTION_5 + "change1";
    userRoleDaoProxy.setRoleDescription(mainTenant_1, ROLE_5, changedDescription1);
    String role_delim = ((DefaultTenantedPrincipleNameResolver) tenantedRoleNameUtils).getDelimeter();
    pentahoRole = userRoleDaoProxy.getRole(null, ROLE_5 + role_delim + mainTenant_1.getRootFolderAbsolutePath());
    assertNotNull(pentahoRole);
    assertEquals(changedDescription1, pentahoRole.getDescription());
    String changedDescription2 = ROLE_DESCRIPTION_5 + "change2";
    userRoleDaoProxy.setRoleDescription(null, ROLE_5 + role_delim + mainTenant_1.getRootFolderAbsolutePath(), changedDescription2);
    pentahoRole = userRoleDaoProxy.getRole(mainTenant_1, ROLE_5);
    assertEquals(changedDescription2, pentahoRole.getDescription());
    userRoleDaoProxy.setRoleDescription(null, ROLE_5 + role_delim + mainTenant_1.getRootFolderAbsolutePath(), null);
    pentahoRole = userRoleDaoProxy.getRole(mainTenant_1, ROLE_5);
    assertNull(pentahoRole.getDescription());
    try {
        userRoleDaoProxy.setRoleDescription(null, null, changedDescription2);
        fail("Exception not thrown");
    } catch (Exception ex) {
        // Expected exception
        assertNotNull(ex);
    }
    try {
        userRoleDaoProxy.setRoleDescription(mainTenant_1, UNKNOWN_ROLE, changedDescription2);
        fail("Exception not thrown");
    } catch (NotFoundException ex) {
        // Expected exception
        assertNotNull(ex);
    }
    logout();
    login("admin", mainTenant_2, new String[] { adminRoleName, authenticatedRoleName });
    try {
        changedDescription1 = ROLE_DESCRIPTION_5 + "change1";
        userRoleDaoProxy.setRoleDescription(mainTenant_1, ROLE_5, changedDescription1);
        fail("Exception not thrown");
    } catch (Throwable th) {
        assertNotNull(th);
    }
    logout();
}
Also used : NotFoundException(org.pentaho.platform.api.engine.security.userroledao.NotFoundException) DefaultTenantedPrincipleNameResolver(org.pentaho.platform.security.userroledao.DefaultTenantedPrincipleNameResolver) IPentahoRole(org.pentaho.platform.api.engine.security.userroledao.IPentahoRole) AlreadyExistsException(org.pentaho.platform.api.engine.security.userroledao.AlreadyExistsException) NotFoundException(org.pentaho.platform.api.engine.security.userroledao.NotFoundException) AccessControlException(javax.jcr.security.AccessControlException) BeansException(org.springframework.beans.BeansException) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

NotFoundException (org.pentaho.platform.api.engine.security.userroledao.NotFoundException)25 Test (org.junit.Test)12 IPentahoUser (org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)12 IOException (java.io.IOException)9 RepositoryException (javax.jcr.RepositoryException)9 AccessControlException (javax.jcr.security.AccessControlException)8 AlreadyExistsException (org.pentaho.platform.api.engine.security.userroledao.AlreadyExistsException)8 ITenant (org.pentaho.platform.api.mt.ITenant)8 BeansException (org.springframework.beans.BeansException)8 PentahoUser (org.pentaho.platform.security.userroledao.PentahoUser)7 Group (org.apache.jackrabbit.api.security.user.Group)5 User (org.apache.jackrabbit.api.security.user.User)5 IPentahoRole (org.pentaho.platform.api.engine.security.userroledao.IPentahoRole)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Matchers.anyString (org.mockito.Matchers.anyString)4 DefaultTenantedPrincipleNameResolver (org.pentaho.platform.security.userroledao.DefaultTenantedPrincipleNameResolver)4 HashSet (java.util.HashSet)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 UserManager (org.apache.jackrabbit.api.security.user.UserManager)2