当前位置: 首页>>代码示例>>Java>>正文


Java PolicyElementDTO类代码示例

本文整理汇总了Java中org.wso2.balana.utils.policy.dto.PolicyElementDTO的典型用法代码示例。如果您正苦于以下问题:Java PolicyElementDTO类的具体用法?Java PolicyElementDTO怎么用?Java PolicyElementDTO使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PolicyElementDTO类属于org.wso2.balana.utils.policy.dto包,在下文中一共展示了PolicyElementDTO类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processPolicyEditorData

import org.wso2.balana.utils.policy.dto.PolicyElementDTO; //导入依赖的package包/类
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));
        }
    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:23,代码来源:PolicyEditorUtil.java

示例2: createPolicy

import org.wso2.balana.utils.policy.dto.PolicyElementDTO; //导入依赖的package包/类
/**
 * 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");
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:45,代码来源:EntitlementPolicyCreator.java

示例3: createPolicyElementDTO

import org.wso2.balana.utils.policy.dto.PolicyElementDTO; //导入依赖的package包/类
public static PolicyElementDTO createPolicyElementDTO(String policy)
        throws EntitlementPolicyCreationException {

    PolicyElementDTO policyElementDTO = new PolicyElementDTO();
    OMElement omElement;
    try {
        omElement = AXIOMUtil.stringToOM(policy);
    } catch (XMLStreamException e) {
        throw new EntitlementPolicyCreationException("Policy can not be converted to OMElement");
    }

    if (omElement != null) {

        policyElementDTO.setPolicyName(omElement.
                getAttributeValue(new QName(EntitlementPolicyConstants.POLICY_ID)));

        String ruleCombiningAlgorithm = omElement.
                getAttributeValue(new QName(EntitlementPolicyConstants.RULE_ALGORITHM));

        try {
            policyElementDTO.setRuleCombiningAlgorithms(ruleCombiningAlgorithm.
                    split(PolicyEditorConstants.RULE_ALGORITHM_IDENTIFIER_3)[1]);
        } catch (Exception ignore) {
            policyElementDTO.setRuleCombiningAlgorithms(ruleCombiningAlgorithm.
                    split(PolicyEditorConstants.RULE_ALGORITHM_IDENTIFIER_1)[1]);
            // if this is also fails, can not edit the policy
        }

        Iterator iterator = omElement.getChildrenWithLocalName(EntitlementPolicyConstants.
                DESCRIPTION_ELEMENT);

        if (iterator.hasNext()) {
            OMElement descriptionElement = (OMElement) iterator.next();
            if (descriptionElement != null && descriptionElement.getText() != null) {
                policyElementDTO.setPolicyDescription(descriptionElement.getText().trim());
            }
        }

    }
    return policyElementDTO;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:42,代码来源:PolicyEditorUtil.java


注:本文中的org.wso2.balana.utils.policy.dto.PolicyElementDTO类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。