Package com.sun.xacml

Examples of com.sun.xacml.AbstractPolicy


    private void readPolicies(PolicyCollection coll, String subdir, PolicyReader reader) {
        List<String> fileNames = getXMLFileNames(subdir);
        for (String fileName : fileNames) {
            try {
                AbstractPolicy policy = reader.readPolicy(new File(fileName));
                if (!coll.addPolicy(policy)) {
                    if (logger.isLoggable(Level.WARNING))
                        logger.log(Level.WARNING, "tried to load the same "
                                + "policy multiple times: " + fileName);
                } else {
                    logger.fine("Read policy(Set) " + policy.getId() + " from "
                            + fileName.toString());
                }

            } catch (ParsingException e) {
                if (logger.isLoggable(Level.WARNING))
View Full Code Here


    }

    @Override
    public PolicyFinderResult findPolicy(EvaluationCtx context) {
        try {
            AbstractPolicy policy = policiesByRequest.getPolicy(context);

            if (policy == null)
                return new PolicyFinderResult();
            else
                return new PolicyFinderResult(policy);
View Full Code Here

    @Override
    public PolicyFinderResult findPolicy(URI idReference, int type, VersionConstraints constraints,
            PolicyMetaData parentMetaData) {

        AbstractPolicy policy = policiesByReference.getPolicy(idReference.toString(), type,
                constraints);

        if (policy == null)
            return new PolicyFinderResult();
        else
View Full Code Here

        } else {
            cacheEntry =  new EntitlementPolicyCacheEntry(hashOfPolicyCollection);
            entitlementPolicyCache.addToCache(cacheKey, cacheEntry);
        }

        AbstractPolicy policy = policies.getPolicy(idReference.toString(), type, constraints);

        if (policy == null) {
            return new PolicyFinderResult();
        } else {
            return new PolicyFinderResult(policy);
View Full Code Here

     *
     * @see com.sun.xacml.finder.PolicyFinderModule#findPolicy(com.sun.xacml.EvaluationCtx)
     */
    public PolicyFinderResult findPolicy(EvaluationCtx context) {

        AbstractPolicy policy;

        try {
            EntitlementPolicyCacheEntry cacheEntry = (EntitlementPolicyCacheEntry)
                                                    entitlementPolicyCache.getValueFromCache(cacheKey);
            if(cacheEntry != null){
View Full Code Here

        // get an iterator over all the identifiers
        Iterator<TreeSet<AbstractPolicy>> it = policies.values().iterator();

        while (it.hasNext()) {
            // for each identifier, get only the most recent policy
            AbstractPolicy policy = it.next().first();

            // see if we match
            MatchResult match = policy.match(context);
            int result = match.getResult();

            // if there was an error, we stop right away
            if (result == MatchResult.INDETERMINATE) {
                log.error("Error occured while processing the XACML policy "
                        + policy.getId().toString());
                throw new EntitlementException(match.getStatus());
            }

            // if we matched, we keep track of the matching policy...
            if (result == MatchResult.MATCH) {
                // ...first checking if this is the first match and if
                // we automatically nest policies

                log.info("Matching XACML policy found " + policy.getId().toString());

                if ((combiningAlg == null) && (list.size() > 0)) {
                    ArrayList<String> code = new ArrayList<String>();
                    code.add(Status.STATUS_PROCESSING_ERROR);
                    Status status = new Status(code, "too many applicable top-level policies");
View Full Code Here

        // walk through the set starting with the most recent version, looking
        // for a match until we exhaust all known versions
        Iterator<AbstractPolicy> it = set.iterator();
        while (it.hasNext()) {
            AbstractPolicy policy = (AbstractPolicy) (it.next());
            if (constraints.meetsConstraint(policy.getVersion())) {
                // we found a valid version, so see if it's the right kind,
                // and if it is then we return it
                if (type == PolicyReference.POLICY_REFERENCE) {
                    if (policy instanceof Policy)
                        return policy;
View Full Code Here

     * @return
     * @throws IdentityException
     */
    private PolicyDTO readPolicyDTO(Resource resource) throws IdentityException {
        String policy = null;
        AbstractPolicy absPolicy = null;
        PolicyDTO dto = null;
        try {
            policy = new String((byte[]) resource.getContent());
            absPolicy = PolicyReader.getInstance(null, null).getPolicy(policy);
            dto = new PolicyDTO();
            dto.setPolicyId(absPolicy.getId().toASCIIString());
            dto.setPolicy(policy);
            if ("true".equals(resource.getProperty("isActive"))) {
                dto.setActive(true);
            }
            dto.setPolicyType(resource.getProperty("policyType"));
View Full Code Here

     * @throws org.wso2.carbon.identity.base.IdentityException
     *             throws if invalid policy or if policy with same id is exist
     */
    public void addPolicy(PolicyDTO policy) throws IdentityException {
        PolicyAdmin policyAdmin;
        AbstractPolicy policyObj;
        EntitlementEngine entitlementEngine = EntitlementEngine
                .getInstance(getGovernanceUserRegistry(), CarbonContext.getCurrentContext().getTenantId());
        policyObj = PolicyReader.getInstance(null, null).getPolicy(policy.getPolicy());
        if (policyObj != null) {
            policyAdmin = new PolicyAdmin(new PolicyStore(getGovernanceUserRegistry()));
            policy.setPolicyId(policyObj.getId().toASCIIString());
            // All the policies wont be active at the time been added.
            policy.setActive(policy.isActive());
            if (getPolicy(policy.getPolicyId()) != null) {
                throw new IdentityException(
                        "An Entitlement Policy with the given ID already exists");
View Full Code Here

     * @throws org.wso2.carbon.identity.base.IdentityException
     *             throws if invalid policy
     */
    public void updatePolicy(PolicyDTO policy) throws IdentityException {
        PolicyAdmin policyAdmin;
        AbstractPolicy policyObj;
        EntitlementEngine entitlementEngine = EntitlementEngine
                .getInstance(getGovernanceUserRegistry(), CarbonContext.getCurrentContext().getTenantId());
        policyObj = PolicyReader.getInstance(null, null).getPolicy(policy.getPolicy());
        if (policyObj != null) {
            policyAdmin = new PolicyAdmin(new PolicyStore(getGovernanceUserRegistry()));
            policy.setPolicyId(policyObj.getId().toASCIIString());
            policyAdmin.addOrUpdatePolicy(policy);
            // Reload the policies to the memory.
            entitlementEngine.getRegistryModule().init(null);
        } else {
            throw new IdentityException("Invalid Policy");
View Full Code Here

TOP

Related Classes of com.sun.xacml.AbstractPolicy

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.