使用opensaml解组XACML Policie文件

时间:2011-10-10 12:19:26

标签: java unmarshalling xacml opensaml

有没有人可以给我一个好的教程链接,可以让我知道如何使用policie文件中的openSAML2 api构建XACMLObject? 谢谢

2 个答案:

答案 0 :(得分:1)

我没有为此目的使用OpenSAML库。但我已经用于其他一些涉及XACML请求和响应的目的。以下内容可帮助您了解相关信息。它正在从String创建XACMLRequest。

private String extractXACMLRequest(String decisionQuery) throws Exception {
    RequestType xacmlRequest = null;
    doBootstrap();
    String queryString = null;
    XACMLAuthzDecisionQueryType xacmlAuthzDecisionQuery;
    try {
        xacmlAuthzDecisionQuery = (XACMLAuthzDecisionQueryType) unmarshall(decisionQuery);
        //Access the XACML request only if Issuer and the Signature are valid.
        if (validateIssuer(xacmlAuthzDecisionQuery.getIssuer())) {
                if (validateSignature(xacmlAuthzDecisionQuery.getSignature())) {
                    xacmlRequest = xacmlAuthzDecisionQuery.getRequest();
                } else {
                    log.debug("The submitted signature is not valid!");
                }
        } else {
            log.debug("The submitted issuer is not valid!");
        }

        if (xacmlRequest != null) {
            queryString = marshall(xacmlRequest);
            queryString = queryString.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "").replace("\n", "");
        }
        return queryString;
    } catch (Exception e) {
        log.error("Error unmarshalling the XACMLAuthzDecisionQuery.", e);
        throw new Exception("Error unmarshalling the XACMLAuthzDecisionQuery.", e);
    }

}

答案 1 :(得分:0)

您希望使用sun XACML或JAXB来编组/解组XACML策略而不是openSAML2。