use of org.wso2.carbon.user.mgt.common.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());
}
}
}
use of org.wso2.carbon.user.mgt.common.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;
}
use of org.wso2.carbon.user.mgt.common.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.";
}
}
use of org.wso2.carbon.user.mgt.common.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);
}
Aggregations