001: /*
002: * KeyInfoConfirmationData.java
003: *
004: * Created on September 20, 2006, 1:08 PM
005: *
006: * To change this template, choose Tools | Template Manager
007: * and open the template in the editor.
008: */
009:
010: package com.sun.xml.wss.saml.assertion.saml20.jaxb20;
011:
012: import com.sun.xml.security.core.dsig.KeyInfoType;
013: import com.sun.xml.wss.logging.LogDomainConstants;
014: import com.sun.xml.wss.saml.SAMLException;
015: import com.sun.xml.wss.saml.util.SAML20JAXBUtil;
016: import com.sun.xml.wss.saml.util.SAMLJAXBUtil;
017: import java.security.PublicKey;
018: import java.util.logging.Logger;
019: import javax.xml.bind.JAXBContext;
020: import javax.xml.bind.JAXBElement;
021: import org.w3c.dom.Element;
022:
023: /**
024: *
025: * @author root
026: */
027: public class KeyInfoConfirmationData
028: extends
029: com.sun.xml.wss.saml.internal.saml20.jaxb20.KeyInfoConfirmationDataType
030: implements com.sun.xml.wss.saml.KeyInfoConfirmationData {
031:
032: protected PublicKey keyInfoKeyValue = null;
033: // public static KeyInfoType keyInfo = null;
034:
035: protected static final Logger log = Logger.getLogger(
036: LogDomainConstants.WSS_API_DOMAIN,
037: LogDomainConstants.WSS_API_DOMAIN_BUNDLE);
038:
039: /**
040: * Constructs a KeyInfoConfirmationData element from an existing
041: * XML block.
042: *
043: * @param KeyInfoConfirmationData a DOM Element representing the
044: * <code>KeyInfoConfirmationData</code> object.
045: * @throws SAMLException
046: */
047: public static KeyInfoConfirmationData fromElement(
048: org.w3c.dom.Element element) throws SAMLException {
049: try {
050: JAXBContext jc = SAML20JAXBUtil.getJAXBContext();
051:
052: javax.xml.bind.Unmarshaller u = jc.createUnmarshaller();
053: return (KeyInfoConfirmationData) u.unmarshal(element);
054: } catch (Exception ex) {
055: throw new SAMLException(ex.getMessage());
056: }
057: }
058:
059: /**
060: * Constructs an <code>SubjectConfirmationData</code> instance.
061: *
062: * @param confirmationMethods A set of <code>confirmationMethods</code>
063: * each of which is a URI (String) that identifies a protocol
064: * used to authenticate a <code>Subject</code>. Please refer to
065: * <code>draft-sstc-core-25</code> Section 7 for
066: * a list of URIs identifying common authentication protocols.
067: * @param SubjectConfirmationDataData Additional authentication information to
068: * be used by a specific authentication protocol. Can be passed as
069: * null if there is no <code>SubjectConfirmationDataData</code> for the
070: * <code>SubjectConfirmationData</code> object.
071: * @param keyInfo An XML signature element that specifies a cryptographic
072: * key held by the <code>Subject</code>.
073: * @exception SAMLException if the input data is invalid or
074: * <code>confirmationMethods</code> is empty.
075: */
076:
077: public KeyInfoConfirmationData(Element keyInfo)
078: throws SAMLException {
079:
080: JAXBContext jc = null;
081: javax.xml.bind.Unmarshaller u = null;
082:
083: //Unmarshal to JAXB KeyInfo Object and set it
084: try {
085: jc = SAMLJAXBUtil.getJAXBContext();
086: u = jc.createUnmarshaller();
087: } catch (Exception ex) {
088: throw new SAMLException(ex.getMessage());
089: }
090:
091: try {
092: if (keyInfo != null) {
093: this .setKeyInfo(((KeyInfoType) ((JAXBElement) u
094: .unmarshal(keyInfo)).getValue()));
095: }
096: } catch (Exception ex) {
097: // log here
098: throw new SAMLException(ex);
099: }
100: }
101:
102: public void setKeyInfo(KeyInfoType value) {
103: //this.keyInfo = value;
104: this.getContent().add(value);
105: }
106: }
|