org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName Java Examples

The following examples show how to use org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Util.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
public static FlaggedName[] doFlaggedNamePaging(int pageNumber, FlaggedName[] flaggedName) {

        int itemsPerPageInt = SecurityUIConstants.DEFAULT_ITEMS_PER_PAGE;
        FlaggedName[] returnedFlaggedNameSet;

        int startIndex = pageNumber * itemsPerPageInt;
        int endIndex = (pageNumber + 1) * itemsPerPageInt;
        if (itemsPerPageInt < flaggedName.length - 1) {
            returnedFlaggedNameSet = new FlaggedName[itemsPerPageInt];
        } else {
            returnedFlaggedNameSet = new FlaggedName[flaggedName.length - 1];
        }
        for (int i = startIndex, j = 0; i < endIndex && i < flaggedName.length - 1; i++, j++) {
            returnedFlaggedNameSet[j] = flaggedName[i];
        }

        return returnedFlaggedNameSet;
    }
 
Example #2
Source File: QueueUserAuthorizationTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * Cleans up the test case effects. Created roles and internal queue related roles are created.
 *
 * @throws java.rmi.RemoteException
 * @throws UserAdminUserAdminException
 */
@AfterMethod(alwaysRun = true)
public void cleanUpAfterScenario() throws RemoteException, UserAdminUserAdminException {
    // Deleting roles of the users used in the test case
    userManagementClient.deleteRole(CREATE_PUB_SUB_QUEUE_ROLE);
    userManagementClient.deleteRole(PUB_SUB_QUEUE_ROLE);
    userManagementClient.deleteRole(NO_PERMISSION_QUEUE_ROLE);

    // Deleting internal roles specific to queues
    FlaggedName[] allRoles = userManagementClient.getAllRolesNames("*", 10);
    for (FlaggedName allRole : allRoles) {
        if (QUEUE_PREFIX.contains(allRole.getItemName())) {
            userManagementClient.deleteRole(allRole.getItemName());
        }
    }
}
 
Example #3
Source File: SubTopicUserAuthorizationTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * Cleans up the test case effects. Created roles and internal role related roles are deleted.
 *
 * @throws RemoteException
 * @throws UserAdminUserAdminException
 */
@AfterMethod(alwaysRun = true)
public void cleanUp() throws RemoteException, UserAdminUserAdminException {
    // Deleting roles of the users used in the test case
    userManagementClient.deleteRole(CREATE_PUB_SUB_TOPIC_ROLE);
    userManagementClient.deleteRole(PUB_SUB_TOPIC_ROLE);
    userManagementClient.deleteRole(NO_PERMISSION_TOPIC_ROLE);

    // Deleting internal roles specific to topics
    FlaggedName[] allRoles = userManagementClient.getAllRolesNames("*", 10);
    for (FlaggedName allRole : allRoles) {
        if (allRole.getItemName().contains(TOPIC_PREFIX)) {
            userManagementClient.deleteRole(allRole.getItemName());
        }
    }
}
 
Example #4
Source File: TopicUserAuthorizationTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * Cleans up the test case effects. Created roles and internal role related roles are created.
 *
 * @throws RemoteException
 * @throws UserAdminUserAdminException
 */
@AfterMethod(alwaysRun = true)
public void cleanUp() throws RemoteException, UserAdminUserAdminException {
    // Deleting roles of the users used in the test case
    userManagementClient.deleteRole(CREATE_PUB_SUB_TOPIC_ROLE);
    userManagementClient.deleteRole(PUB_SUB_TOPIC_ROLE);
    userManagementClient.deleteRole(NO_PERMISSION_TOPIC_ROLE);

    // Deleting internal roles specific to topics
    FlaggedName[] allRoles = userManagementClient.getAllRolesNames("*", 10);
    for (FlaggedName allRole : allRoles) {
        if (allRole.getItemName().contains(TOPIC_PREFIX)) {
            userManagementClient.deleteRole(allRole.getItemName());
        }
    }
}
 
Example #5
Source File: Util.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public static FlaggedName[] doFlaggedNamePaging(int pageNumber, FlaggedName[] flaggedName) {

        int itemsPerPageInt = SecurityUIConstants.DEFAULT_ITEMS_PER_PAGE;
        FlaggedName[] returnedFlaggedNameSet;

        int startIndex = pageNumber * itemsPerPageInt;
        int endIndex = (pageNumber + 1) * itemsPerPageInt;
        if (itemsPerPageInt < flaggedName.length - 1) {
            returnedFlaggedNameSet = new FlaggedName[itemsPerPageInt];
        } else {
            returnedFlaggedNameSet = new FlaggedName[flaggedName.length - 1];
        }
        for (int i = startIndex, j = 0; i < endIndex && i < flaggedName.length - 1; i++, j++) {
            returnedFlaggedNameSet[j] = flaggedName[i];
        }

        return returnedFlaggedNameSet;
    }
 
Example #6
Source File: UserSignUpWorkflowExecutorTest.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@Before
public void init() throws Exception {
    ServiceReferenceHolder serviceReferenceHolder = TestUtils.getServiceReferenceHolder();
    RealmService realmService = Mockito.mock(RealmService.class);
    UserRealm userRealm = Mockito.mock(UserRealm.class);
    userStoreManager = Mockito.mock(UserStoreManager.class);
    PowerMockito.mockStatic(CarbonUtils.class);
    userAdminStub = Mockito.mock(UserAdminStub.class);
    userRegistrationAdminServiceStub = Mockito.mock(UserRegistrationAdminServiceStub.class);
    serviceClient =  Mockito.mock(ServiceClient.class);;
    PowerMockito.whenNew(UserAdminStub.class).withAnyArguments().thenReturn(userAdminStub);
    PowerMockito.whenNew(UserRegistrationAdminServiceStub.class).withAnyArguments().thenReturn
            (userRegistrationAdminServiceStub);
    PowerMockito.when(userRegistrationAdminServiceStub._getServiceClient()).thenReturn(serviceClient);
    Mockito.when(serviceClient.getOptions()).thenReturn(new Options());
    Mockito.when(serviceReferenceHolder.getRealmService()).thenReturn(realmService);
    Mockito.when(realmService.getBootstrapRealm()).thenReturn(userRealm);
    Mockito.when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
    PowerMockito.doNothing().when(CarbonUtils.class, "setBasicAccessSecurityHeaders", Mockito.anyString(),
            Mockito.anyString(), Mockito.anyBoolean(), (ServiceClient) Mockito.anyObject());
    FlaggedName flaggedName = new FlaggedName();
    flaggedName.setSelected(true);
    flaggedName.setItemName(role);
    flaggedNames = new FlaggedName[]{flaggedName};
}
 
Example #7
Source File: PaginatedNamesBean.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public String[] getNamesAsString() {
    List<String> list = new ArrayList<String>();

    for (FlaggedName name : names) {

        list.add(name.getItemName());
    }
    return list.toArray(new String[list.size()]);
}
 
Example #8
Source File: UserAdminClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public FlaggedName[] listUserByClaimWithPermission(ClaimValue claimValue, String filter, String permission, int
        limit) throws AxisFault {
    try {
        org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue newClaimValue = new
                org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue();
        newClaimValue.setClaimURI(newClaimValue.getClaimURI());
        newClaimValue.setValue(newClaimValue.getValue());
        return stub.listUserByClaimWithPermission(newClaimValue, filter, permission, limit);
    } catch (Exception e) {
        handleException(e);
    }

    return new FlaggedName[0];
}
 
Example #9
Source File: UserAdminClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public FlaggedName[] listUserByClaim(ClaimValue claimValue, String filter, int limit) throws AxisFault {
    try {
        org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue abcdClaimValue = new
               org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue();
        abcdClaimValue.setClaimURI(claimValue.getClaimURI());
        abcdClaimValue.setValue(claimValue.getValue());
        return stub.listUserByClaim(abcdClaimValue, filter, limit);
    } catch (Exception e) {
        handleException(e);
    }

    return new FlaggedName[0];
}
 
Example #10
Source File: UserAdminClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public FlaggedName[] listAllUsersWithPermission(String filter, String permission, int limit) throws AxisFault {
    try {
        return stub.listAllUsersWithPermission(filter, permission, limit);
    } catch (Exception e) {
        handleException(e);
    }
    return new FlaggedName[0];
}
 
Example #11
Source File: UserAdminClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public FlaggedName[] listAllUsers(String filter, int limit) throws AxisFault {
    try {
        return stub.listAllUsers(filter, limit);
    } catch (Exception e) {
        handleException(e);
    }
    return new FlaggedName[0];
}
 
Example #12
Source File: UserAdminClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public FlaggedName[] getUsersOfRole(String roleName, String filter, int limit) throws AxisFault {
    try {
        return stub.getUsersOfRole(roleName, filter, limit);
    } catch (Exception e) {
        handleException(e);
    }
    return new FlaggedName[0];
}
 
Example #13
Source File: UserAdminClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public FlaggedName[] getRolesOfUser(String userName, String filter, int limit) throws AxisFault {
    try {
        return stub.getRolesOfUser(userName, filter, limit);
    } catch (Exception e) {
        handleException(e);
    }
    return new FlaggedName[0];
}
 
Example #14
Source File: UserAdminClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public FlaggedName[] getAllPermittedRoleNames(String filter, String permission, int limit) throws AxisFault {
    try {
        return stub.getAllPermittedRoleNames(filter, permission, limit);
    } catch (Exception e) {
        handleException(e);
    }
    return new FlaggedName[0];
}
 
Example #15
Source File: UserAdminClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public FlaggedName[] getAllRolesNames(String filter, int limit) throws AxisFault {
    try {
        return stub.getAllRolesNames(filter, limit);
    } catch (Exception e) {
        handleException(e);
    }
    return new FlaggedName[0];
}
 
Example #16
Source File: UserSignUpWorkflowExecutor.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * Method updates Roles users with subscriber role
 * @param serverURL
 * @param adminUsername
 * @param adminPassword
 * @param userName
 * @param role
 * @throws Exception
 */
protected static void updateRolesOfUser(String serverURL, String adminUsername,
                                        String adminPassword, String userName, String role)
                                                                                           throws Exception {
	if (log.isDebugEnabled()) {
		log.debug("Adding Subscriber role to " + userName);
	}

	String url = serverURL + "UserAdmin";
	RealmService realmService = ServiceReferenceHolder.getInstance().getRealmService();
	UserRealm realm = realmService.getBootstrapRealm();
	UserStoreManager manager = realm.getUserStoreManager();
	if (!manager.isExistingRole(role)){
		log.error("Could not find role " + role + " in the user store");
		throw new Exception("Could not find role " + role + " in the user store");
	}

	UserAdminStub userAdminStub = new UserAdminStub(url);
	CarbonUtils.setBasicAccessSecurityHeaders(adminUsername, adminPassword, userAdminStub._getServiceClient());
	FlaggedName[] flaggedNames = userAdminStub.getRolesOfUser(userName, "*", -1);
	List<String> roles = new ArrayList<String>();
	if (flaggedNames != null) {
		for (FlaggedName flaggedName : flaggedNames) {
			if (flaggedName.getSelected()) {
				roles.add(flaggedName.getItemName());
			}
		}
	}
	roles.add(role);
	userAdminStub.updateRolesOfUser(userName, roles.toArray(new String[roles.size()]));
}
 
Example #17
Source File: UserSignUpSimpleWorkflowExecutorTest.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Test
public void testExecutingUserSignUpSimpleWorkflow() throws APIManagementException, org
        .wso2.carbon.user.core.UserStoreException, RemoteException, UserAdminUserAdminException {
    Map<String, Boolean> roleMap = new HashMap<String, Boolean>();
    roleMap.put(signUpRole, false);

    UserRegistrationConfigDTO userRegistrationConfigDTO = new UserRegistrationConfigDTO();
    userRegistrationConfigDTO.setAdminUserName("admin");
    userRegistrationConfigDTO.setAdminPassword("admin");
    userRegistrationConfigDTO.setRoles(roleMap);

    PowerMockito.when(SelfSignUpUtil.getSignupConfiguration(tenantDomain)).thenReturn(userRegistrationConfigDTO);
    PowerMockito.when(SelfSignUpUtil.getRoleNames(userRegistrationConfigDTO)).thenCallRealMethod();
    PowerMockito.when(apiManagerConfiguration.getFirstProperty(APIConstants.AUTH_MANAGER_URL)).thenReturn
            ("https://localhost:9443/services/");
    Mockito.when(userStoreManager.isExistingUser(username)).thenReturn(true);
    Mockito.when(userStoreManager.isExistingRole("Internal/" + signUpRole)).thenReturn(true);
    FlaggedName flaggedName = new FlaggedName();
    flaggedName.setSelected(true);
    flaggedName.setItemName(signUpRole);
    FlaggedName[] flaggedNames = {flaggedName};
    Mockito.when(userAdminStub.getRolesOfUser(username, "*", -1)).thenReturn(flaggedNames);

    try {
        Assert.assertNotNull(userSignUpSimpleWorkflowExecutor.execute(workflowDTO));
    } catch (WorkflowException e) {
        Assert.fail("Unexpected WorkflowException has thrown while executing the user signup simple workflow");
    }
}
 
Example #18
Source File: UserAdminClient.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
public FlaggedName[] getAllRolesNames(String filter, int limit) throws AxisFault {
    try {
        return stub.getAllRolesNames(filter, limit);
    } catch (Exception e) {
        handleException(e);
    }
    return new FlaggedName[0];
}
 
Example #19
Source File: UserAdminClient.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
public FlaggedName[] listAllUsersWithPermission(String filter, String permission, int limit) throws AxisFault {
    try {
        return stub.listAllUsersWithPermission(filter, permission, limit);
    } catch (Exception e) {
        handleException(e);
    }
    return new FlaggedName[0];
}
 
Example #20
Source File: UserAdminClient.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
public FlaggedName[] getRolesOfUser(String userName, String filter, int limit) throws AxisFault {
    try {
        return stub.getRolesOfUser(userName, filter, limit);
    } catch (Exception e) {
        handleException(e);
    }
    return new FlaggedName[0];
}
 
Example #21
Source File: UserAdminClient.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
public FlaggedName[] getUsersOfRole(String roleName, String filter, int limit) throws AxisFault {
    try {
        return stub.getUsersOfRole(roleName, filter, limit);
    } catch (Exception e) {
        handleException(e);
    }
    return new FlaggedName[0];
}
 
Example #22
Source File: UserAdminClient.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
public FlaggedName[] getAllPermittedRoleNames(String filter, String permission, int limit) throws AxisFault {
    try {
        return stub.getAllPermittedRoleNames(filter, permission, limit);
    } catch (Exception e) {
        handleException(e);
    }
    return new FlaggedName[0];
}
 
Example #23
Source File: UserAdminClient.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
public FlaggedName[] listAllUsers(String filter, int limit) throws AxisFault {
    try {
        return stub.listAllUsers(filter, limit);
    } catch (Exception e) {
        handleException(e);
    }
    return new FlaggedName[0];
}
 
Example #24
Source File: UserAdminClient.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
public FlaggedName[] listUserByClaim(ClaimValue claimValue, String filter, int limit) throws AxisFault {
    try {
        org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue abcdClaimValue = new
               org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue();
        abcdClaimValue.setClaimURI(claimValue.getClaimURI());
        abcdClaimValue.setValue(claimValue.getValue());
        return stub.listUserByClaim(abcdClaimValue, filter, limit);
    } catch (Exception e) {
        handleException(e);
    }

    return new FlaggedName[0];
}
 
Example #25
Source File: UserAdminClient.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
public FlaggedName[] listUserByClaimWithPermission(ClaimValue claimValue, String filter, String permission, int
        limit) throws AxisFault {
    try {
        org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue newClaimValue = new
                org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue();
        newClaimValue.setClaimURI(newClaimValue.getClaimURI());
        newClaimValue.setValue(newClaimValue.getValue());
        return stub.listUserByClaimWithPermission(newClaimValue, filter, permission, limit);
    } catch (Exception e) {
        handleException(e);
    }

    return new FlaggedName[0];
}
 
Example #26
Source File: PaginatedNamesBean.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
public String[] getNamesAsString() {
    List<String> list = new ArrayList<String>();

    for (FlaggedName name : names) {

        list.add(name.getItemName());
    }
    return list.toArray(new String[list.size()]);
}
 
Example #27
Source File: UserManagementClient.java    From product-es with Apache License 2.0 4 votes vote down vote up
public void updateUsersOfRole(String roleName, FlaggedName[] userList) throws RemoteException, UserAdminUserAdminException{
    userAdminStub.updateUsersOfRole(roleName, userList);
}
 
Example #28
Source File: Util.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
public static PaginatedNamesBean retrievePaginatedFlaggedName(int pageNumber, List<FlaggedName> names) {

        PaginatedNamesBean bean = new PaginatedNamesBean();
        DataPaginator.doPaging(pageNumber, names, bean);
        return bean;
    }
 
Example #29
Source File: UserManagementClient.java    From product-es with Apache License 2.0 4 votes vote down vote up
public FlaggedName[] getRolesOfUser(String userName, String filter, int limit)throws RemoteException, UserAdminUserAdminException {
    return userAdminStub.getRolesOfUser(userName, filter, limit);
}
 
Example #30
Source File: UserManagementClient.java    From product-es with Apache License 2.0 4 votes vote down vote up
public FlaggedName[] getUsersOfRole(String roleName, String filter, int limit) throws RemoteException, UserAdminUserAdminException {
    return userAdminStub.getUsersOfRole(roleName, filter, limit);
}