Package com.adito.security

Examples of com.adito.security.Role


     * @throws Exception
     */
    @Test
    public void checkResourceAccessViaRole() throws Exception {
        User user = createAccount();
        Role role = createRole();
        user = updateAccountRoles(user, Collections.singleton(role));
        Realm realm = getDefaultRealm();
        Policy policy = createPolicy(realm);
        T resource = createResource();
        getPolicyService().attachResourceToPolicy(resource, policy, 0, realm);
View Full Code Here


     * @throws Exception
     */
    @Test
    public void checkAllAccessRightsViaRole() throws Exception {
        User user = createAccount();
        Role role = createRole();
        user = updateAccountRoles(user, Collections.singleton(role));
        Realm realm = getDefaultRealm();
        Policy policy = createPolicy(realm);
        T resource = createResource();
        getPolicyService().attachResourceToPolicy(resource, policy, 0, realm);
View Full Code Here

     * @throws Exception
     */
    @Test
    public void checkNoAccessRightsViaRole() throws Exception {
        User user = createAccount();
        Role role = createRole();
        user = updateAccountRoles(user, Collections.singleton(role));
        Realm realm = getDefaultRealm();
        Policy policy = createPolicy(realm);
        T resource = createResource();
        getPolicyService().attachResourceToPolicy(resource, policy, 0, realm);
View Full Code Here

     * @throws Exception
     */
    @Test
    public void checkDeleteAccessRightsViaRole() throws Exception {
        User user = createAccount();
        Role role = createRole();
        user = updateAccountRoles(user, Collections.singleton(role));
        Realm realm = getDefaultRealm();
        Policy policy = createPolicy(realm);
        T resource = createResource();
        getPolicyService().attachResourceToPolicy(resource, policy, 0, realm);
View Full Code Here

     * @throws Exception
     */
    @Test
    public void checkCreateEditAssignAssignAccessRightsViaRole() throws Exception {
        User user = createAccount();
        Role role = createRole();
        user = updateAccountRoles(user, Collections.singleton(role));
        Realm realm = getDefaultRealm();
        Policy policy = createPolicy(realm);
        T resource = createResource();
        getPolicyService().attachResourceToPolicy(resource, policy, 0, realm);
View Full Code Here

     * @throws Exception
     */
    @Test
    public void checkEditAssignAccessRightsViaRole() throws Exception {
        User user = createAccount();
        Role role = createRole();
        user = updateAccountRoles(user, Collections.singleton(role));
        Realm realm = getDefaultRealm();
        Policy policy = createPolicy(realm);
        T resource = createResource();
        getPolicyService().attachResourceToPolicy(resource, policy, 0, realm);
View Full Code Here

     * @throws Exception
     */
    @Test
    public void checkAssignAccessRightsViaRole() throws Exception {
        User user = createAccount();
        Role role = createRole();
        user = updateAccountRoles(user, Collections.singleton(role));
        Realm realm = getDefaultRealm();
        Policy policy = createPolicy(realm);
        T resource = createResource();
        getPolicyService().attachResourceToPolicy(resource, policy, 0, realm);
View Full Code Here

                            CoreAttributeConstants.EVENT_ATTR_POLICY_NAME,
                            pol.getResourceName()).addAttribute(CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_ID, user.getPrincipalName()));
                }
                for (Iterator i = ((PropertyList) seq.getAttribute(PolicyPrincipalSelectionForm.ATTR_SELECTED_ROLES, null))
                                .iterator(); i.hasNext();) {
                    Role role = udb.getRole((String) i.next());
                    PolicyDatabaseFactory.getInstance().grantPolicyToPrincipal(pol,
                                    role);

                    CoreServlet.getServlet().fireCoreEvent(new CoreEvent(this, CoreEventConstants.GRANT_POLICY_TO_PRINCIPAL, pol, getSessionInfo(request),
                        CoreEvent.STATE_SUCCESSFUL).addAttribute(CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_TYPE, "group").addAttribute(
                        CoreAttributeConstants.EVENT_ATTR_POLICY_NAME,
                        pol.getResourceName()).addAttribute(CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_ID, role.getPrincipalName()));
                }
                actionStatus.add(new WizardActionStatus(WizardActionStatus.COMPLETED_OK,
                                "policyWizard.policyFinish.status.grantedToPrincipals"));
            } catch (Exception e) {
                log.error("Failed to grant principals to policy.", e);
View Full Code Here

    @Test
    public void createNormalRole() throws Exception {
        Role[] currentRoles = getDefaultUserDatabase().listAllRoles(UserDatabase.WILDCARD_SEARCH, Integer.MAX_VALUE);
        int currentNumberOfRoles = currentRoles.length;
        String roleName = "jb";
        Role role = createRole(roleName);
        assertEquals("There should only be the one user and he is the super user.", getDefaultUserDatabase().listAllRoles(
            UserDatabase.WILDCARD_SEARCH, Integer.MAX_VALUE).length, currentNumberOfRoles + 1);
        deleteRole(role);
        assertEquals("There should only be the one user and he is the super user.", getDefaultUserDatabase().listAllRoles(
            UserDatabase.WILDCARD_SEARCH, Integer.MAX_VALUE).length, currentNumberOfRoles);
View Full Code Here

     * @throws Exception
     */
    @Test
    public void assignRolesToUser() throws Exception {
        String userName = "jb";
        Role role = createRole("Group1");
        User user = createAccount(userName, "qwqwqw", "james@localhost", "James Robninson");
        user = updateAccountRoles(user, Collections.singleton(role));
        assertEquals("The roles should be the same.", role.getPrincipalName(), user.getRoles()[0].getPrincipalName());
        user = updateAccountRoles(user, Collections.<Role> emptyList());
        User[] usersInRole = getUserService().getDefaultUserDatabase().getUsersInRole(role);
        assertEquals("There should be the user in the list.", usersInRole.length, 0);
        User retrievedUser2 = getUserService().getDefaultUserDatabase().getAccount(user.getPrincipalName());
        List<Role> usersRoles2 = Arrays.asList(retrievedUser2.getRoles());
View Full Code Here

TOP

Related Classes of com.adito.security.Role

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.