Search in sources :

Example 41 with FlaggedName

use of org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName in project product-is by wso2.

the class UserManagementClient method updateUserListOfRole.

public void updateUserListOfRole(String roleName, String[] addingUsers, String[] deletingUsers) throws UserAdminUserAdminException, RemoteException {
    List<FlaggedName> updatedUserList = new ArrayList<FlaggedName>();
    if (addingUsers != null) {
        for (String addUser : addingUsers) {
            FlaggedName fName = new FlaggedName();
            fName.setItemName(addUser);
            fName.setSelected(true);
            updatedUserList.add(fName);
        }
    }
    // add deleted users to the list
    if (deletingUsers != null) {
        for (String deletedUser : deletingUsers) {
            FlaggedName fName = new FlaggedName();
            fName.setItemName(deletedUser);
            fName.setSelected(false);
            updatedUserList.add(fName);
        }
    }
    // call userAdminStub to update user list of role
    userAdminStub.updateUsersOfRole(roleName, updatedUserList.toArray(new FlaggedName[updatedUserList.size()]));
    // if delete users in retrieved list, fail
    if (deletingUsers != null) {
        for (String deletedUser : deletingUsers) {
            FlaggedName[] verifyingList;
            verifyingList = userAdminStub.getUsersOfRole(roleName, deletedUser, LIMIT);
            assert (!verifyingList[0].getSelected());
        }
    }
    if (addingUsers != null) {
        // if all added users are not in list fail
        for (String addingUser : addingUsers) {
            FlaggedName[] verifyingList = userAdminStub.getUsersOfRole(roleName, addingUser, LIMIT);
            assert (verifyingList[0].getSelected());
        }
    }
}
Also used : FlaggedName(org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName) ArrayList(java.util.ArrayList)

Example 42 with FlaggedName

use of org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName in project product-is by wso2.

the class UserManagementClient method roleNameExists.

public boolean roleNameExists(String roleName) throws RemoteException, UserAdminUserAdminException {
    FlaggedName[] roles;
    roles = userAdminStub.getAllRolesNames(roleName, LIMIT);
    for (FlaggedName role : roles) {
        if (role.getItemName().equals(roleName)) {
            log.info("Role name " + roleName + " already exists");
            return true;
        }
    }
    return false;
}
Also used : FlaggedName(org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName)

Example 43 with FlaggedName

use of org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName in project product-is by wso2.

the class UserManagementClient method addRoleWithUser.

private void addRoleWithUser(String roleName, String userName, String[] permission) throws RemoteException, UserAdminUserAdminException {
    userAdminStub.addRole(roleName, new String[] { userName }, null, false);
    FlaggedName[] roles = userAdminStub.getAllRolesNames(roleName, 100);
    for (FlaggedName role : roles) {
        if (!role.getItemName().equals(roleName)) {
            continue;
        } else {
            assert (role.getItemName().equals(roleName));
        }
        assert false : "Role: " + roleName + " was not added properly.";
    }
}
Also used : FlaggedName(org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName)

Example 44 with FlaggedName

use of org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName in project product-is by wso2.

the class OAuthAdminServiceTestCase method testInit.

@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
    super.init();
    logManger = new AuthenticatorClient(backendURL);
    userMgtClient = new UserManagementClient(backendURL, sessionCookie);
    // create a user with capital letters in user name
    userMgtClient.addUser(userName, password, null, "default");
    String[] userList = new String[] { userName };
    FlaggedName[] userFlagList = new FlaggedName[userList.length];
    for (int i = 0; i < userFlagList.length; i++) {
        FlaggedName flaggedName = new FlaggedName();
        flaggedName.setItemName(userList[i]);
        flaggedName.setSelected(true);
        userFlagList[i] = flaggedName;
    }
    userMgtClient.updateUsersOfRole("admin", userFlagList);
    String cookie = this.logManger.login(userName, password, isServer.getInstance().getHosts().get("default"));
    adminClient = new OauthAdminClient(backendURL, cookie);
}
Also used : OauthAdminClient(org.wso2.identity.integration.common.clients.oauth.OauthAdminClient) AuthenticatorClient(org.wso2.carbon.integration.common.admin.client.AuthenticatorClient) FlaggedName(org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName) UserManagementClient(org.wso2.identity.integration.common.clients.UserManagementClient) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

FlaggedName (org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName)31 ArrayList (java.util.ArrayList)14 FlaggedName (org.wso2.carbon.user.mgt.common.FlaggedName)13 Test (org.testng.annotations.Test)12 UserAdminException (org.wso2.carbon.user.mgt.common.UserAdminException)10 AbstractUserStoreManager (org.wso2.carbon.user.core.common.AbstractUserStoreManager)9 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)8 HashMap (java.util.HashMap)7 RegistryException (org.wso2.carbon.registry.api.RegistryException)7 UserStoreException (org.wso2.carbon.user.core.UserStoreException)7 UserStoreManager (org.wso2.carbon.user.core.UserStoreManager)7 JDBCUserStoreManager (org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager)7 ClaimValue (org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue)7 SetEnvironment (org.wso2.carbon.automation.engine.annotations.SetEnvironment)4 Mockito.anyString (org.mockito.Mockito.anyString)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 BeforeTest (org.testng.annotations.BeforeTest)3 AuthorizationManager (org.wso2.carbon.user.api.AuthorizationManager)3 UserAdminUserAdminException (org.wso2.carbon.user.mgt.stub.UserAdminUserAdminException)3 Field (java.lang.reflect.Field)2