001: /*
002: * $Id: AuthzDecisionStatement.java,v 1.3 2007/01/08 16:05:59 shyam_rao Exp $
003: */
004:
005: /*
006: * The contents of this file are subject to the terms
007: * of the Common Development and Distribution License
008: * (the License). You may not use this file except in
009: * compliance with the License.
010: *
011: * You can obtain a copy of the license at
012: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
013: * See the License for the specific language governing
014: * permissions and limitations under the License.
015: *
016: * When distributing Covered Code, include this CDDL
017: * Header Notice in each file and include the License file
018: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
019: * If applicable, add the following below the CDDL Header,
020: * with the fields enclosed by brackets [] replaced by
021: * you own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
025: */
026:
027: package com.sun.xml.wss.saml.assertion.saml20.jaxb20;
028:
029: import com.sun.xml.wss.saml.SAMLException;
030: import com.sun.xml.wss.logging.LogDomainConstants;
031: import com.sun.xml.wss.saml.internal.saml20.jaxb20.AuthzDecisionStatementType;
032: import com.sun.xml.wss.saml.internal.saml20.jaxb20.DecisionType;
033: import com.sun.xml.wss.saml.util.SAML20JAXBUtil;
034: import org.w3c.dom.Element;
035:
036: import java.util.List;
037: import java.util.logging.Logger;
038:
039: import javax.xml.bind.JAXBContext;
040:
041: /**
042: *The <code>AuthzDecisionStatement</code> element supplies a statement
043: *by the issuer that the request for access by the specified subject to the
044: *specified resource has resulted in the specified decision on the basis of
045: * some optionally specified evidence.
046: */
047: public class AuthzDecisionStatement extends AuthzDecisionStatementType
048: implements com.sun.xml.wss.saml.AuthnDecisionStatement {
049:
050: protected static final Logger log = Logger.getLogger(
051: LogDomainConstants.WSS_API_DOMAIN,
052: LogDomainConstants.WSS_API_DOMAIN_BUNDLE);
053:
054: /**
055: *Default constructor
056: */
057: protected AuthzDecisionStatement() {
058: super ();
059: }
060:
061: /**
062: * Constructs an <code>AuthorizationStatement</code> element from an
063: * existing XML block.
064: *
065: * @param element representing a DOM tree element
066: * @exception SAMLException if there is an error in the sender or in
067: * the element definition.
068: */
069: public static AuthzDecisionStatementType fromElement(Element element)
070: throws SAMLException {
071: try {
072: JAXBContext jc = SAML20JAXBUtil.getJAXBContext();
073:
074: javax.xml.bind.Unmarshaller u = jc.createUnmarshaller();
075: return (AuthzDecisionStatementType) u.unmarshal(element);
076: } catch (Exception ex) {
077: throw new SAMLException(ex.getMessage());
078: }
079: }
080:
081: private void setAction(List action) {
082: this .action = action;
083: }
084:
085: /**
086: * Constructs an instance of <code>AuthzDecisionStatement</code>.
087: *
088: * @param subject (required) A Subject object
089: * @param resource (required) A String identifying the resource to which
090: * access authorization is sought.
091: * @param decision (required) The decision rendered by the issuer with
092: * respect to the specified resource. The value is of the
093: * <code>DecisionType</code> simple type.
094: * @param action (required) A List of Action objects specifying the set of
095: * actions authorized to be performed on the specified resource.
096: * @param evidence (optional) An Evidence object representing a set of
097: * assertions that the issuer replied on in making decisions.
098: * @exception SAMLException if there is an error in the sender.
099: */
100: public AuthzDecisionStatement(String resource, String decision,
101: List action, Evidence evidence) {
102:
103: setResource(resource);
104: setDecision(DecisionType.fromValue(decision));
105: setAction(action);
106: setEvidence(evidence);
107: }
108: }
|