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;
}
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.";
}
}
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, boolean isSharedRole) throws RemoteException, UserAdminUserAdminException {
userAdminStub.addRole(roleName, new String[] { userName }, null, isSharedRole);
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.stub.types.carbon.FlaggedName in project product-is by wso2.
the class SCIMServiceProviderGroupTestCase method listGroup.
@Test(alwaysRun = true, description = "list SCIM Groups", dependsOnMethods = { "getGroup" })
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
public void listGroup() throws Exception {
SCIMResponseHandler responseHandler = new SCIMResponseHandler();
responseHandler.setSCIMClient(scimClient);
// set the handler in wink client config
ClientConfig clientConfig = new ClientConfig();
clientConfig.handlers(new ClientHandler[] { responseHandler });
// create a wink rest client with the above config
RestClient restClient = new RestClient(clientConfig);
BasicAuthInfo encodedBasicAuthInfo = SCIMUtils.getBasicAuthInfo(userInfo);
// create resource endpoint to access a known user resource.
Resource groupResource = restClient.resource(scim_url + "Groups/" + scimGroupId);
String response = groupResource.header(SCIMConstants.AUTHORIZATION_HEADER, encodedBasicAuthInfo.getAuthorizationHeader()).contentType(SCIMConstants.APPLICATION_JSON).accept(SCIMConstants.APPLICATION_JSON).get(String.class);
log.info(response.toString());
FlaggedName[] roleNames = userMgtClient.listRoles("eng", 100);
for (FlaggedName role : roleNames) {
if (!role.getItemName().contains("false")) {
Assert.assertTrue(response.contains(role.getItemName()));
}
}
}
use of org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName in project product-is by wso2.
the class UserManagementServiceAbstractTest method testUpdateUsersOfRole.
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = "wso2.is", description = "Check update users of role", dependsOnMethods = "testAddRemoveRolesOfUser")
public void testUpdateUsersOfRole() throws Exception {
String[] userList = new String[] { newUserName };
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(newUserRole, userFlagList);
Assert.assertTrue(nameExists(userMgtClient.getUsersOfRole(newUserRole, newUserName, 0), newUserName), "Adding user to role has failed");
// Calling with same user list should delete the users.
for (int i = 0; i < userFlagList.length; i++) {
userFlagList[i].setSelected(false);
}
userMgtClient.updateUsersOfRole(userRoleTmp, userFlagList);
Assert.assertFalse(nameExists(userMgtClient.getUsersOfRole(userRoleTmp, newUserName, 0), newUserName), "Deleting user from role has failed");
// Assert.assertFalse(nameExists(userMgtClient.getUsersOfRole("umRole1", "user2", 0), "user2"), "Deleting user2 from role has failed");
}
Aggregations