Examples of Policy


Examples of com.adito.policyframework.Policy

    /* (non-Javadoc)
     * @see com.adito.policyframework.actions.AbstractResourcesDispatchAction#remove(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
    public ActionForward remove(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        Policy resource = getSelectedResource(form);
        super.remove(mapping, form, request, response);
        saveMessage(request, "policy.deleted.message", resource);
        return getRedirectWithMessages(mapping, request);
    }
View Full Code Here

Examples of com.adito.policyframework.Policy

     */
    @Test
    public void createPolicy() throws Exception {
        Realm realm = getUserService().getRealm(1);
        assertEquals("There should be only one policy", getPolicyService().getPolicies().size(), 1);
        Policy policy = getPolicyService().createPolicy("Policy A", "Policy A description", Policy.TYPE_NORMAL, realm.getRealmID());
        assertEquals("There should be only two policies", getPolicyService().getPolicies().size(), 2);
        getPolicyService().deletePolicy(policy.getResourceId());
        assertEquals("There should be only one policy", getPolicyService().getPolicies().size(), 1);
    }
View Full Code Here

Examples of com.adito.policyframework.Policy

     */
    @Test
    public void createPersonalPolicy() throws Exception {
        Realm realm = getUserService().getDefaultRealm();
        assertEquals("There should be only one policy (Everyone policy)", getPolicyService().getPoliciesExcludePersonal(realm), getPolicyService().getPolicies(realm));
        Policy policy = getPolicyService().createPolicy("Personal Policy A", "Personal Policy A description", Policy.TYPE_PERSONAL, realm.getRealmID());
        assertEquals("There should be two policies", 2, getPolicyService().getPolicies().size());
        assertEquals("There should be only one global policy", 1, getPolicyService().getPoliciesExcludePersonal(realm).size());
        getPolicyService().deletePolicy(policy.getResourceId());
        assertEquals("There should be only one policy (Everyone policy)", getPolicyService().getPoliciesExcludePersonal(realm), getPolicyService().getPolicies(realm));
    }
View Full Code Here

Examples of com.adito.policyframework.Policy

     */
    @Test
    public void updatePolicyName() throws Exception {
        String newPolicyName = "NewName";
        Realm realm = getUserService().getRealm(1);
        Policy policy = createPolicy(realm);
        policy.setResourceName(newPolicyName);
        getPolicyService().updatePolicy(policy);
        Policy updatedPolicy = getPolicyService().getPolicy(policy.getResourceId());
        assertEquals("The new policy name should be " + newPolicyName, newPolicyName, updatedPolicy.getResourceName());
        getPolicyService().deletePolicy(policy.getResourceId());
    }
View Full Code Here

Examples of com.adito.policyframework.Policy

     */
    @Test
    public void updatePolicyDescription() throws Exception {
        String newPolicyDescription = "NewDescription";
        Realm realm = getUserService().getRealm(1);
        Policy policy = createPolicy(realm);
        policy.setResourceDescription(newPolicyDescription);
        getPolicyService().updatePolicy(policy);
        Policy updatedPolicy = getPolicyService().getPolicy(policy.getResourceId());
        assertEquals("The new policy description should be " + newPolicyDescription, newPolicyDescription, updatedPolicy.getResourceDescription());
        getPolicyService().deletePolicy(policy.getResourceId());
    }
View Full Code Here

Examples of com.adito.policyframework.Policy

     * @throws Exception
     */
    @Test
    public void checkPolicyRetrieval() throws Exception {
        Realm realm = getUserService().getRealm(1);
        Policy policy = createPolicy(realm);
        Policy retrievedById = getPolicyService().getPolicy(policy.getResourceId());
        Policy retrievedByName = getPolicyService().getPolicyByName(policy.getResourceName(), realm.getResourceId());
        assertEquals("The policies should be the same.", retrievedById, retrievedByName);
        getPolicyService().deletePolicy(policy.getResourceId());
    }
View Full Code Here

Examples of com.adito.policyframework.Policy

     * @throws Exception
     */
    @Test
    public void attachDetachPolicyToUser() throws Exception {
        Realm realm = getUserService().getDefaultRealm();
        Policy policy = createPolicy(realm);
        int users = getUserService().getDefaultUserDatabase().listAllUsers(UserDatabase.WILDCARD_SEARCH, Integer.MAX_VALUE).length;
        User user = createAccount();
        assertEquals(
            getUserService().getDefaultUserDatabase().listAllUsers(UserDatabase.WILDCARD_SEARCH, Integer.MAX_VALUE).length,
            users + 1);
        getPolicyService().grantPolicyToPrincipal(policy, user);
        assertTrue("The policy should be granted", PolicyDatabaseFactory.getInstance().isPolicyGrantedToUser(policy, user));
        getPolicyService().revokePolicyFromPrincipal(policy, user);
        assertFalse("The policy should not be granted", PolicyDatabaseFactory.getInstance().isPolicyGrantedToUser(policy, user));
        getUserService().getDefaultUserDatabase().deleteAccount(user);
        assertEquals(
            getUserService().getDefaultUserDatabase().listAllUsers(UserDatabase.WILDCARD_SEARCH, Integer.MAX_VALUE).length, users);
        getPolicyService().deletePolicy(policy.getResourceId());
    }
View Full Code Here

Examples of com.adito.policyframework.Policy

     * @throws Exception
     */
    @Test
    public void attachDetachPolicyToRole() throws Exception {
        Realm realm = getUserService().getDefaultRealm();
        Policy policy = createPolicy(realm);
        User user = createAccount();
        Role role = createRole("Group1");
        user = updateAccountRoles(user, Collections.singleton(role));
        getPolicyService().grantPolicyToPrincipal(policy, role);
        assertTrue("The policy should be granted", PolicyDatabaseFactory.getInstance().isPolicyGrantedToUser(policy, user));
        getPolicyService().revokePolicyFromPrincipal(policy, role);
        assertFalse("The policy should not be granted", PolicyDatabaseFactory.getInstance().isPolicyGrantedToUser(policy, user));
        getUserService().getDefaultUserDatabase().deleteAccount(user);
        getPolicyService().deletePolicy(policy.getResourceId());
    }
View Full Code Here

Examples of com.adito.policyframework.Policy

    }
   
    @Test
    public void checkResourceAccessRights() throws Exception {
        Realm realm = getDefaultRealm();
        Policy policy = createPolicy(realm);
        User user = createAccount();
        getPolicyService().grantPolicyToPrincipal(policy, user);
       
        AccessRights accessRights = createAssignAccessRights(getResourceType().getPermissionClass());
        PropertyList selectedPolicies = PropertyList.createFromArray(new int[] {policy.getResourceId()});
        PolicyDatabaseFactory.getInstance().attachResourceToPolicyList(accessRights, selectedPolicies, getSessionInfo());
        PropertyProfile resource = createResource();
        assertTrue("Should be, as one already exists.", getPolicyService().isPrincipalGrantedResourcesOfType(user, resource.getResourceType(), null));
        assertEquals("Should be only one.", getPolicyService().getGrantedResourcesOfType(user, getResourceType()).size(), 1);
       
        PolicyDatabaseFactory.getInstance().attachResourceToPolicyList(resource, selectedPolicies, getSessionInfo());
        assertEquals("Should be two.", getPolicyService().getGrantedResourcesOfType(user, getResourceType()).size(), 2);
       
        PolicyDatabaseFactory.getInstance().detachResourceFromPolicyList(resource, getSessionInfo());
        assertEquals("Should be only one.", getPolicyService().getGrantedResourcesOfType(user, getResourceType()).size(), 1);
        getPolicyService().revokePolicyFromPrincipal(policy, user);
        deleteAccount(user);
       
        PolicyDatabaseFactory.getInstance().detachResourceFromPolicyList(accessRights, getSessionInfo());
        deleteResource(resource);
        getPolicyService().deleteAccessRights(accessRights.getResourceId());
        getPolicyService().deletePolicy(policy.getResourceId());
    }
View Full Code Here

Examples of com.adito.policyframework.Policy

    protected WizardActionStatus attachToPoliciesAndAddToFavorites(String messagePrefix, AbstractWizardSequence seq, Resource resource, boolean addToFavorites, HttpServletRequest request) {
        PropertyList selectedPolicies = (PropertyList) seq.getAttribute(AbstractWizardPolicySelectionForm.ATTR_SELECTED_POLICIES,
            null);
        try {
            if (SessionInfo.USER_CONSOLE_CONTEXT == this.getSessionInfo(request).getNavigationContext()) {
                Policy policy = PolicyDatabaseFactory.getInstance().getPolicyByName(
                    PolicyUtil.getPersonalPolicyName(getSessionInfo(request).getUser().getPrincipalName()),
                    getSessionInfo(request).getUser().getRealm().getRealmID());
                if (null == policy) {
                    policy = PolicyDatabaseFactory.getInstance().createPolicy(
                        PolicyUtil.getPersonalPolicyName(getSessionInfo(request).getUser().getPrincipalName()),
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.