Java Code Examples for org.wso2.balana.utils.policy.dto.PolicyElementDTO#setVersion()

The following examples show how to use org.wso2.balana.utils.policy.dto.PolicyElementDTO#setVersion() . 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: PolicyEditorUtil.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
public static void processPolicyEditorData(PolicyElementDTO policyElementDTO, String[] policyEditorData) {

        List<String> targetList = new ArrayList<String>();

        if (policyEditorData != null) {
            for (String data : policyEditorData) {
                if (data.contains("|")) {
                    String identifier = data.substring(0, data.indexOf("|"));
                    if (("policy").equals(identifier)) {
                        targetList.add(data.substring(data.indexOf("|") + 1));
                    }
                }
            }

            policyElementDTO.setPolicyName(targetList.get(0));
            policyElementDTO.setRuleCombiningAlgorithms(targetList.get(1));
            if (targetList.get(2) != null) {
                policyElementDTO.setPolicyDescription(targetList.get(2));
            }
            policyElementDTO.setVersion(targetList.get(3));
        }
    }
 
Example 2
Source File: PolicyEditorUtil.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
public static void processPolicyEditorData(PolicyElementDTO policyElementDTO, String[] policyEditorData) {

        List<String> targetList = new ArrayList<String>();

        if (policyEditorData != null) {
            for (String data : policyEditorData) {
                if (data.contains("|")) {
                    String identifier = data.substring(0, data.indexOf("|"));
                    if (("policy").equals(identifier)) {
                        targetList.add(data.substring(data.indexOf("|") + 1));
                    }
                }
            }

            policyElementDTO.setPolicyName(targetList.get(0));
            policyElementDTO.setRuleCombiningAlgorithms(targetList.get(1));
            if (targetList.get(2) != null) {
                policyElementDTO.setPolicyDescription(targetList.get(2));
            }
            policyElementDTO.setVersion(targetList.get(3));
        }
    }
 
Example 3
Source File: PolicyEditorUtil.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public static void processPolicyEditorData(PolicyElementDTO policyElementDTO, String[] policyEditorData) {

        List<String> targetList = new ArrayList<String>();

        if (policyEditorData != null) {
            for (String data : policyEditorData) {
                if (data.contains("|")) {
                    String identifier = data.substring(0, data.indexOf("|"));
                    if (("policy").equals(identifier)) {
                        targetList.add(data.substring(data.indexOf("|") + 1));
                    }
                }
            }

            policyElementDTO.setPolicyName(targetList.get(0));
            policyElementDTO.setRuleCombiningAlgorithms(targetList.get(1));
            if (targetList.get(2) != null) {
                policyElementDTO.setPolicyDescription(targetList.get(2));
            }
            policyElementDTO.setVersion(targetList.get(3));
        }
    }
 
Example 4
Source File: EntitlementPolicyCreator.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Create XACML policy using the data received from basic policy wizard
 *
 * @param policyDTO PolicyDTO
 * @return String object of the XACML policy
 * @throws PolicyEditorException throws
 */
public String createPolicy(PolicyDTO policyDTO) throws PolicyEditorException {

    if (policyDTO == null) {
        throw new PolicyEditorException("Policy object can not be null");
    }

    PolicyElementDTO policyElementDTO = new PolicyElementDTO();
    policyElementDTO.setPolicyName(policyDTO.getPolicyId());
    policyElementDTO.setRuleCombiningAlgorithms(policyDTO.getRuleAlgorithm());
    policyElementDTO.setPolicyDescription(policyDTO.getDescription());
    policyElementDTO.setVersion(policyDTO.getVersion());

    if (policyDTO.getTargetDTO() != null) {
        TargetElementDTO targetElementDTO = PolicyEditorUtil.
                createTargetElementDTO(policyDTO.getTargetDTO());
        policyElementDTO.setTargetElementDTO(targetElementDTO);
    }

    if (policyDTO.getRuleDTOs() != null) {
        for (RuleDTO ruleDTO : policyDTO.getRuleDTOs()) {
            RuleElementDTO ruleElementDTO = PolicyEditorUtil.createRuleElementDTO(ruleDTO);
            policyElementDTO.addRuleElementDTO(ruleElementDTO);
        }
    }

    if (policyDTO.getObligationDTOs() != null) {
        List<ObligationElementDTO> obligationElementDTOs = PolicyEditorUtil.
                createObligation(policyDTO.getObligationDTOs());
        policyElementDTO.setObligationElementDTOs(obligationElementDTOs);
    }

    try {
        return PolicyBuilder.getInstance().build(policyElementDTO);
    } catch (PolicyBuilderException e) {
        throw new PolicyEditorException("Error while building XACML Policy");
    }
}
 
Example 5
Source File: EntitlementPolicyCreator.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Create XACML policy using the data received from basic policy wizard
 *
 * @param policyDTO PolicyDTO
 * @return String object of the XACML policy
 * @throws PolicyEditorException throws
 */
public String createPolicy(PolicyDTO policyDTO) throws PolicyEditorException {

    if (policyDTO == null) {
        throw new PolicyEditorException("Policy object can not be null");
    }

    PolicyElementDTO policyElementDTO = new PolicyElementDTO();
    policyElementDTO.setPolicyName(policyDTO.getPolicyId());
    policyElementDTO.setRuleCombiningAlgorithms(policyDTO.getRuleAlgorithm());
    policyElementDTO.setPolicyDescription(policyDTO.getDescription());
    policyElementDTO.setVersion(policyDTO.getVersion());

    if (policyDTO.getTargetDTO() != null) {
        TargetElementDTO targetElementDTO = PolicyEditorUtil.
                createTargetElementDTO(policyDTO.getTargetDTO());
        policyElementDTO.setTargetElementDTO(targetElementDTO);
    }

    if (policyDTO.getRuleDTOs() != null) {
        for (RuleDTO ruleDTO : policyDTO.getRuleDTOs()) {
            RuleElementDTO ruleElementDTO = PolicyEditorUtil.createRuleElementDTO(ruleDTO);
            policyElementDTO.addRuleElementDTO(ruleElementDTO);
        }
    }

    if (policyDTO.getObligationDTOs() != null) {
        List<ObligationElementDTO> obligationElementDTOs = PolicyEditorUtil.
                createObligation(policyDTO.getObligationDTOs());
        policyElementDTO.setObligationElementDTOs(obligationElementDTOs);
    }

    try {
        return PolicyBuilder.getInstance().build(policyElementDTO);
    } catch (PolicyBuilderException e) {
        throw new PolicyEditorException("Error while building XACML Policy");
    }
}