KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > xml > crypto > dsig > keyinfo > KeyInfo


1 /*
2  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
3  */

4 /*
5  * $Id: KeyInfo.java,v 1.7 2005/05/10 16:35:34 mullan Exp $
6  */

7 package javax.xml.crypto.dsig.keyinfo;
8
9 import java.util.List JavaDoc;
10 import javax.xml.crypto.MarshalException;
11 import javax.xml.crypto.XMLCryptoContext;
12 import javax.xml.crypto.XMLStructure;
13
14 /**
15  * A representation of the XML <code>KeyInfo</code> element as defined in
16  * the <a HREF="http://www.w3.org/TR/xmldsig-core/">
17  * W3C Recommendation for XML-Signature Syntax and Processing</a>.
18  * A <code>KeyInfo</code> contains a list of {@link XMLStructure}s, each of
19  * which contain information that enables the recipient(s) to obtain the key
20  * needed to validate an XML signature. The XML Schema Definition is defined as:
21  *
22  * <pre>
23  * &lt;element name="KeyInfo" type="ds:KeyInfoType"/&gt;
24  * &lt;complexType name="KeyInfoType" mixed="true"&gt;
25  * &lt;choice maxOccurs="unbounded"&gt;
26  * &lt;element ref="ds:KeyName"/&gt;
27  * &lt;element ref="ds:KeyValue"/&gt;
28  * &lt;element ref="ds:RetrievalMethod"/&gt;
29  * &lt;element ref="ds:X509Data"/&gt;
30  * &lt;element ref="ds:PGPData"/&gt;
31  * &lt;element ref="ds:SPKIData"/&gt;
32  * &lt;element ref="ds:MgmtData"/&gt;
33  * &lt;any processContents="lax" namespace="##other"/&gt;
34  * &lt;!-- (1,1) elements from (0,unbounded) namespaces --&gt;
35  * &lt;/choice&gt;
36  * &lt;attribute name="Id" type="ID" use="optional"/&gt;
37  * &lt;/complexType&gt;
38  * </pre>
39  *
40  * A <code>KeyInfo</code> instance may be created by invoking one of the
41  * {@link KeyInfoFactory#newKeyInfo newKeyInfo} methods of the
42  * {@link KeyInfoFactory} class, and passing it a list of one or more
43  * <code>XMLStructure</code>s and an optional id parameter;
44  * for example:
45  * <pre>
46  * KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM");
47  * KeyInfo keyInfo = factory.newKeyInfo
48  * (Collections.singletonList(factory.newKeyName("Alice"), "keyinfo-1"));
49  * </pre>
50  *
51  * <p><code>KeyInfo</code> objects can also be marshalled to XML by invoking
52  * the {@link #marshal marshal} method.
53  *
54  * @author Sean Mullan
55  * @author JSR 105 Expert Group
56  * @since 1.6
57  * @see KeyInfoFactory#newKeyInfo(List)
58  * @see KeyInfoFactory#newKeyInfo(List, String)
59  */

60 public interface KeyInfo extends XMLStructure {
61
62     /**
63      * Returns an {@link java.util.Collections#unmodifiableList unmodifiable
64      * list} containing the key information. Each entry of the list is
65      * an {@link XMLStructure}.
66      *
67      * <p>If there is a public subclass representing the type of
68      * <code>XMLStructure</code>, it is returned as an instance of that
69      * class (ex: an <code>X509Data</code> element would be returned as an
70      * instance of {@link javax.xml.crypto.dsig.keyinfo.X509Data}).
71      *
72      * @return an unmodifiable list of one or more <code>XMLStructure</code>s
73      * in this <code>KeyInfo</code>. Never returns <code>null</code> or an
74      * empty list.
75      */

76     List JavaDoc getContent();
77
78     /**
79      * Return the optional Id attribute of this <code>KeyInfo</code>, which
80      * may be useful for referencing this <code>KeyInfo</code> from other
81      * XML structures.
82      *
83      * @return the Id attribute of this <code>KeyInfo</code> (may be
84      * <code>null</code> if not specified)
85      */

86     String JavaDoc getId();
87
88     /**
89      * Marshals the key info to XML.
90      *
91      * @param parent a mechanism-specific structure containing the parent node
92      * that the marshalled key info will be appended to
93      * @param context the <code>XMLCryptoContext</code> containing additional
94      * context (may be null if not applicable)
95      * @throws ClassCastException if the type of <code>parent</code> or
96      * <code>context</code> is not compatible with this key info
97      * @throws MarshalException if the key info cannot be marshalled
98      * @throws NullPointerException if <code>parent</code> is <code>null</code>
99      */

100     void marshal(XMLStructure parent, XMLCryptoContext context)
101         throws MarshalException;
102 }
103
Popular Tags