當前位置: 首頁>>代碼示例>>Java>>正文


Java Advice類代碼示例

本文整理匯總了Java中org.wso2.balana.xacml3.Advice的典型用法代碼示例。如果您正苦於以下問題:Java Advice類的具體用法?Java Advice怎麽用?Java Advice使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Advice類屬於org.wso2.balana.xacml3包,在下文中一共展示了Advice類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: combine

import org.wso2.balana.xacml3.Advice; //導入依賴的package包/類
@Override
public AbstractResult combine(EvaluationCtx context, List parameters, List policyElements) {

    List<ObligationResult> denyObligations = new ArrayList<ObligationResult>();
    List<Advice> denyAdvices = new ArrayList<Advice>();

    for (Object policyElement : policyElements) {
        AbstractPolicy policy = ((PolicyCombinerElement) (policyElement)).getPolicy();
        AbstractResult result = policy.evaluate(context);
        int value = result.getDecision();

        // if there was a value of PERMIT, then regardless of what else
        // we've seen, we always return PERMIT
        if (value == AbstractResult.DECISION_PERMIT) {
            return result;
        } else if(value == AbstractResult.DECISION_DENY){
            denyObligations.addAll(result.getObligations());
            denyAdvices.addAll(result.getAdvices());
        }
    }

    // if there is not any value of PERMIT. The return DENY
    return ResultFactory.getFactory().getResult(AbstractResult.DECISION_DENY, denyObligations,
                                                                        denyAdvices, context);
}
 
開發者ID:FTSRG,項目名稱:mondo-collab-framework,代碼行數:26,代碼來源:DenyUnlessPermitPolicyAlg.java

示例2: combine

import org.wso2.balana.xacml3.Advice; //導入依賴的package包/類
@Override
public AbstractResult combine(EvaluationCtx context, List parameters, List ruleElements) {

    List<ObligationResult> permitObligations = new ArrayList<ObligationResult>();
    List<Advice> permitAdvices= new ArrayList<Advice>();

    for (Object ruleElement : ruleElements) {
        Rule rule = ((RuleCombinerElement) (ruleElement)).getRule();
        AbstractResult result = rule.evaluate(context);
        int value = result.getDecision();

        // if there was a value of DENY, then regardless of what else
        // we've seen, we always return DENY
        if (value == AbstractResult.DECISION_DENY) {
            return result;
        } else if(value == AbstractResult.DECISION_PERMIT){
            permitObligations.addAll(result.getObligations());
            permitAdvices.addAll(result.getAdvices());
        }
    }

    // if there is not any value of DENY. The return PERMIT
    return ResultFactory.getFactory().getResult(AbstractResult.DECISION_PERMIT,
                                                permitObligations, permitAdvices, context);
}
 
開發者ID:FTSRG,項目名稱:mondo-collab-framework,代碼行數:26,代碼來源:PermitUnlessDenyRuleAlg.java

示例3: combine

import org.wso2.balana.xacml3.Advice; //導入依賴的package包/類
@Override
public AbstractResult combine(EvaluationCtx context, List parameters, List policyElements) {

    List<ObligationResult> permitObligations = new ArrayList<ObligationResult>();
    List<Advice> permitAdvices= new ArrayList<Advice>();

    for (Object policyElement : policyElements) {
        AbstractPolicy policy = ((PolicyCombinerElement) (policyElement)).getPolicy();
        AbstractResult result = policy.evaluate(context);
        int value = result.getDecision();

        // if there was a value of DENY, then regardless of what else
        // we've seen, we always return DENY
        if (value == AbstractResult.DECISION_DENY) {
            return result;
        } else if(value == AbstractResult.DECISION_PERMIT){
            permitObligations.addAll(result.getObligations());
            permitAdvices.addAll(result.getAdvices());
        }
    }

    // if there is not any value of DENY. The return PERMIT
    return ResultFactory.getFactory().getResult(AbstractResult.DECISION_PERMIT,
                                                permitObligations, permitAdvices, context);
}
 
開發者ID:FTSRG,項目名稱:mondo-collab-framework,代碼行數:26,代碼來源:PermitUnlessDenyPolicyAlg.java

示例4: combine

import org.wso2.balana.xacml3.Advice; //導入依賴的package包/類
@Override
public AbstractResult combine(EvaluationCtx context, List parameters, List ruleElements) {

    List<ObligationResult> denyObligations = new ArrayList<ObligationResult>();
    List<Advice> denyAdvices = new ArrayList<Advice>();
    
    for (Object ruleElement : ruleElements) {
        Rule rule = ((RuleCombinerElement) (ruleElement)).getRule();
        AbstractResult result = rule.evaluate(context);
        int value = result.getDecision();

        // if there was a value of PERMIT, then regardless of what else
        // we've seen, we always return PERMIT
        if (value == AbstractResult.DECISION_PERMIT) {
            return result;
        } else if(value == AbstractResult.DECISION_DENY){
            denyObligations.addAll(result.getObligations());
            denyAdvices.addAll(result.getAdvices());
        }
    }

    // if there is not any value of PERMIT. The return DENY
    return ResultFactory.getFactory().getResult(AbstractResult.DECISION_DENY, denyObligations,
                                                                        denyAdvices, context);
}
 
開發者ID:FTSRG,項目名稱:mondo-collab-framework,代碼行數:26,代碼來源:DenyUnlessPermitRuleAlg.java

示例5: parseAdvices

import org.wso2.balana.xacml3.Advice; //導入依賴的package包/類
/**
 * Helper method that handles the Advices
 * 
 * @param root the DOM root of the AssociatedAdviceType XML type
 * @return a <code>List</code> of <code>Advice</code>
 * @throws ParsingException  if any issues in parsing DOM
 */
private static List<Advice> parseAdvices(Node root) throws ParsingException {

    List<Advice> list = new ArrayList<Advice>();

    NodeList nodes = root.getChildNodes();
    for (int i = 0; i < nodes.getLength(); i++) {
        Node node = nodes.item(i);
        if (DOMHelper.getLocalName(node).equals("Advice")){
            list.add(Advice.getInstance(node));
        }
    }

    if (list.size() == 0) {
        throw new ParsingException("AssociatedAdviceType must not be empty");
    }
    return list;
}
 
開發者ID:FTSRG,項目名稱:mondo-collab-framework,代碼行數:25,代碼來源:Result.java

示例6: processObligationAndAdvices

import org.wso2.balana.xacml3.Advice; //導入依賴的package包/類
/**
 * helper method to evaluate the obligations and advice expressions
 *
 * @param evaluationCtx context of a single policy evaluation
 * @param effect policy effect
 * @param result result of combining algorithm
 */
private void processObligationAndAdvices(EvaluationCtx evaluationCtx, int effect, AbstractResult result){

    if(obligationExpressions != null && obligationExpressions.size() > 0){
        Set<ObligationResult>  results = new HashSet<ObligationResult>();
        for(AbstractObligation obligationExpression : obligationExpressions){
            if(obligationExpression.getFulfillOn() == effect) {
                results.add(obligationExpression.evaluate(evaluationCtx));
            }
        }
        result.getObligations().addAll(results);
    }

    if(adviceExpressions != null && adviceExpressions.size() > 0){
        Set<Advice>  advices = new HashSet<Advice>();
        for(AdviceExpression adviceExpression : adviceExpressions){
            if(adviceExpression.getAppliesTo() == effect) {
                advices.add(adviceExpression.evaluate(evaluationCtx));
            }
        }
        result.getAdvices().addAll(advices);
    }
}
 
開發者ID:FTSRG,項目名稱:mondo-collab-framework,代碼行數:30,代碼來源:AbstractPolicy.java

示例7: adviceToJsonObject

import org.wso2.balana.xacml3.Advice; //導入依賴的package包/類
/**
 * Private method to convert Balana <code>{@link Advice}</code> to <code>{@link JsonObject}</code>
 *
 * @param advice <code>{@link Advice}</code>
 * @return <code>{@link JsonObject}</code>
 */
private static JsonObject adviceToJsonObject(Advice advice) {
    JsonObject jsonAdvice = new JsonObject();

    jsonAdvice.addProperty(EntitlementEndpointConstants.OBLIGATION_OR_ADVICE_ID, advice.getAdviceId().toString());
    JsonArray attributeAssignments = new JsonArray();
    for (AttributeAssignment aa : advice.getAssignments()) {
        attributeAssignments.add(attributeAssignmentToJsonObject(aa));
    }
    jsonAdvice.add(EntitlementEndpointConstants.ATTRIBUTE_ASSIGNMENTS, attributeAssignments);

    return jsonAdvice;
}
 
開發者ID:wso2,項目名稱:carbon-identity-framework,代碼行數:19,代碼來源:JSONResponseWriter.java

示例8: testWriteWithAdvices

import org.wso2.balana.xacml3.Advice; //導入依賴的package包/類
@Test
public void testWriteWithAdvices() throws URISyntaxException {

    List<AttributeAssignment> assignments = new ArrayList<>();
    String content = "Error: Channel request is not WEB.";
    URI type = new URI("http://www.w3.org/2001/XMLSchema#string");
    URI attributeId = new URI("urn:oasis:names:tc:xacml:3.0:example:attribute:text");
    AttributeAssignment attributeAssignment = new AttributeAssignment(attributeId, type, null, content, null);
    assignments.add(attributeAssignment);

    List<Advice> adviceResults = new ArrayList<>();
    Advice adviceResult = new Advice(new URI("channel_ko"), assignments);
    adviceResults.add(adviceResult);

    List<String> codes = new ArrayList<>();
    codes.add("urn:oasis:names:tc:xacml:1.0:status:ok");
    AbstractResult abstractResult = new Result(1, new Status(codes), null, adviceResults, null);

    ResponseCtx responseCtx = new ResponseCtx(abstractResult);

    JSONResponseWriter jsonResponseWriter = new JSONResponseWriter();
    try {
        JsonObject jsonObject = jsonResponseWriter.write(responseCtx);
        assertNotNull("Failed to build the XACML json response", jsonObject.toString());
        assertFalse("Failed to build the XACML json response", jsonObject.entrySet().isEmpty());
        for(Map.Entry<String, JsonElement> jsonElementEntry: jsonObject.entrySet()) {
            if (jsonElementEntry.getKey().equals("Response")) {
                JsonArray jsonArray = (JsonArray) jsonElementEntry.getValue();
                assertEquals("Failed to build the XACML json response with correct evaluation",
                        jsonArray.get(0).getAsJsonObject().get("Decision").getAsString(), "Deny");
            }
        }
    } catch (ResponseWriteException e) {
        assertNull("Failed to build the XACML json response", e);
    }

}
 
開發者ID:wso2,項目名稱:carbon-identity-framework,代碼行數:38,代碼來源:TestJSONResponseWriter.java

示例9: processAdvices

import org.wso2.balana.xacml3.Advice; //導入依賴的package包/類
/**
 * helper method to evaluate the  advice expressions
 *
 * @param evaluationCtx context of a single policy evaluation
 * @return set of <code>Advice</code> or null
 */
private List<Advice> processAdvices(EvaluationCtx evaluationCtx){
    if(adviceExpressions != null && adviceExpressions.size() > 0){
        List<Advice>  advices = new ArrayList<Advice>();
        for(AdviceExpression adviceExpression : adviceExpressions){
            if(adviceExpression.getAppliesTo() == effectAttr) {
                advices.add(adviceExpression.evaluate(evaluationCtx));
            }
        }
        return advices;
    }
    return null;
}
 
開發者ID:FTSRG,項目名稱:mondo-collab-framework,代碼行數:19,代碼來源:Rule.java

示例10: Result

import org.wso2.balana.xacml3.Advice; //導入依賴的package包/類
/**
 *
 * @param decision
 * @param status
 * @param obligationResults
 * @param advices
 * @param evaluationCtx
 * @throws IllegalArgumentException
 */
public Result(int decision, Status status, List<ObligationResult> obligationResults,
              List<Advice> advices, EvaluationCtx evaluationCtx) throws IllegalArgumentException {
    super(decision, status, obligationResults, advices, XACMLConstants.XACML_VERSION_3_0);
    if(evaluationCtx != null){
        XACML3EvaluationCtx ctx = (XACML3EvaluationCtx) evaluationCtx;
        this.policyReferences = ctx.getPolicyReferences();
        processAttributes(ctx.getAttributesSet());
    }
}
 
開發者ID:FTSRG,項目名稱:mondo-collab-framework,代碼行數:19,代碼來源:Result.java

示例11: getResult

import org.wso2.balana.xacml3.Advice; //導入依賴的package包/類
/**
 * Returns instance of <code>AbstractResult</code> based one the XACML version.
 * Constructs a <code>AbstractResult</code> object with decision and evaluation ctx
 *
 * @param decision decision the decision effect to include in this result.
 * @param obligationResults a list of <code>ObligationResult</code> objects
 * @param advices a list of <code>Advice</code> objects
 * @param evaluationCtx context of a single policy evaluation
 * @return <code>AbstractResult</code> object
 */
public AbstractResult getResult(int decision, List<ObligationResult> obligationResults,
                                        List<Advice> advices,  EvaluationCtx evaluationCtx) {

    if(evaluationCtx.getXacmlVersion() == XACMLConstants.XACML_VERSION_3_0){
        return new Result(decision, null, obligationResults,
                                                                        advices, evaluationCtx);
    } else {
        return new org.wso2.balana.ctx.xacml2.Result(decision, null, obligationResults);
    }
}
 
開發者ID:FTSRG,項目名稱:mondo-collab-framework,代碼行數:21,代碼來源:ResultFactory.java

示例12: AbstractResult

import org.wso2.balana.xacml3.Advice; //導入依賴的package包/類
/**
 * Constructs a <code>AbstractResult</code> object with decision status data, obligations, advices
 *  and evaluation ctx
 *
 * @param decision the decision effect to include in this result. This must be one of the four
 *            fields in this class.
 * @param status the <code>Status</code> to include in this result
 * @param obligationResults a list of <code>ObligationResult</code> objects
 * @param advices  a list of <code>Advice</code> objects  
 * @param version XACML version
 * @throws IllegalArgumentException if decision is not valid
 */
public AbstractResult(int decision, Status status, List<ObligationResult> obligationResults,
              List<Advice> advices, int version) throws IllegalArgumentException {

    this.version = version;
    
    // check that decision is valid
    if ((decision != DECISION_PERMIT) && (decision != DECISION_DENY)
            && (decision != DECISION_INDETERMINATE) && (decision != DECISION_NOT_APPLICABLE)
            && (decision != DECISION_INDETERMINATE_DENY) && (decision != DECISION_INDETERMINATE_PERMIT)
            && (decision != DECISION_INDETERMINATE_DENY_OR_PERMIT)) {
        throw new IllegalArgumentException("invalid decision value");
    }
    
    this.decision = decision;

    if(obligationResults != null){
        this.obligations = obligationResults;
    }

    if(advices != null){
        this.advices = advices;            
    }

    if (status == null){
        this.status = Status.getOkInstance();
    } else {
        this.status = status;
    }
}
 
開發者ID:FTSRG,項目名稱:mondo-collab-framework,代碼行數:42,代碼來源:AbstractResult.java

示例13: getAdvices

import org.wso2.balana.xacml3.Advice; //導入依賴的package包/類
/**
 * Returns the set of advice that the PEP must fulfill, which may be empty.
 *
 * @return the set of <code>Advice</code>
 */
public List<Advice> getAdvices() {
    if(advices  == null){
        advices = new ArrayList<Advice>();
    }
    return advices;
}
 
開發者ID:FTSRG,項目名稱:mondo-collab-framework,代碼行數:12,代碼來源:AbstractResult.java

示例14: combine

import org.wso2.balana.xacml3.Advice; //導入依賴的package包/類
@Override
public AbstractResult combine(EvaluationCtx context, List parameters, List policyElements) {

    List<ObligationResult> denyObligations = new ArrayList<ObligationResult>();
    List<Advice> denyAdvices = new ArrayList<Advice>();

    for (Object policyElement : policyElements) {
        AbstractPolicy policy = ((PolicyCombinerElement) (policyElement)).getPolicy();
        MatchResult match = policy.match(context);
        if (match.getResult() == MatchResult.MATCH) {
            AbstractResult result = policy.evaluate(context);
            int value = result.getDecision();
            // if there was a value of PERMIT, then regardless of what else
            // we've seen, we always return PERMIT
            if (value == AbstractResult.DECISION_PERMIT) {
                return result;
            } else if(value == AbstractResult.DECISION_DENY){
                denyObligations.addAll(result.getObligations());
                denyAdvices.addAll(result.getAdvices());
            }
        }
    }

    // if there is not any value of PERMIT. The return DENY
    return ResultFactory.getFactory().getResult(AbstractResult.DECISION_DENY, denyObligations,
                                                                        denyAdvices, context);
}
 
開發者ID:wso2,項目名稱:balana,代碼行數:28,代碼來源:DenyUnlessPermitPolicyAlg.java

示例15: combine

import org.wso2.balana.xacml3.Advice; //導入依賴的package包/類
@Override
public AbstractResult combine(EvaluationCtx context, List parameters, List policyElements) {

    List<ObligationResult> permitObligations = new ArrayList<ObligationResult>();
    List<Advice> permitAdvices= new ArrayList<Advice>();

    for (Object policyElement : policyElements) {
        AbstractPolicy policy = ((PolicyCombinerElement) (policyElement)).getPolicy();
        MatchResult match = policy.match(context);
        if (match.getResult() == MatchResult.MATCH) {
            AbstractResult result = policy.evaluate(context);
            int value = result.getDecision();

            // if there was a value of DENY, then regardless of what else
            // we've seen, we always return DENY
            if (value == AbstractResult.DECISION_DENY) {
                return result;
            } else if (value == AbstractResult.DECISION_PERMIT) {
                permitObligations.addAll(result.getObligations());
                permitAdvices.addAll(result.getAdvices());
            }
        }
    }

    // if there is not any value of DENY. The return PERMIT
    return ResultFactory.getFactory().getResult(AbstractResult.DECISION_PERMIT,
                                                permitObligations, permitAdvices, context);
}
 
開發者ID:wso2,項目名稱:balana,代碼行數:29,代碼來源:PermitUnlessDenyPolicyAlg.java


注:本文中的org.wso2.balana.xacml3.Advice類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。