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