1 /*
2  * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 
26 /*
27  * ===========================================================================
28  *
29  * (C) Copyright IBM Corp. 2003 All Rights Reserved.
30  *
31  * ===========================================================================
32  */
33 /*
34  * $Id: XMLObject.java,v 1.5 2005/05/10 16:03:48 mullan Exp $
35  */
36 package javax.xml.crypto.dsig;
37 
38 import java.util.List;
39 import javax.xml.crypto.XMLStructure;
40 
41 /**
42  * A representation of the XML <code>Object</code> element as defined in
43  * the <a href="http://www.w3.org/TR/xmldsig-core/">
44  * W3C Recommendation for XML-Signature Syntax and Processing</a>.
45  * An <code>XMLObject</code> may contain any data and may include optional
46  * MIME type, ID, and encoding attributes. The XML Schema Definition is
47  * defined as:
48  *
49  * <pre><code>
50  * &lt;element name="Object" type="ds:ObjectType"/&gt;
51  * &lt;complexType name="ObjectType" mixed="true"&gt;
52  *   &lt;sequence minOccurs="0" maxOccurs="unbounded"&gt;
53  *     &lt;any namespace="##any" processContents="lax"/&gt;
54  *   &lt;/sequence&gt;
55  *   &lt;attribute name="Id" type="ID" use="optional"/&gt;
56  *   &lt;attribute name="MimeType" type="string" use="optional"/&gt;
57  *   &lt;attribute name="Encoding" type="anyURI" use="optional"/&gt;
58  * &lt;/complexType&gt;
59  * </code></pre>
60  *
61  * A <code>XMLObject</code> instance may be created by invoking the
62  * {@link XMLSignatureFactory#newXMLObject newXMLObject} method of the
63  * {@link XMLSignatureFactory} class; for example:
64  *
65  * <pre>
66  *   XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM");
67  *   Manifest manifest = fac.newManifest(references);
68  *   List&lt;XMLStructure&gt; content = Collections.singletonList(manifest);
69  *   XMLObject object = factory.newXMLObject(content, "object-1", null, null);
70  * </pre>
71  *
72  * <p>Note that this class is named <code>XMLObject</code> rather than
73  * <code>Object</code> to avoid naming clashes with the existing
74  * {@link java.lang.Object java.lang.Object} class.
75  *
76  * @author Sean Mullan
77  * @author JSR 105 Expert Group
78  * @author Joyce L. Leung
79  * @since 1.6
80  * @see XMLSignatureFactory#newXMLObject(List, String, String, String)
81  */
82 public interface XMLObject extends XMLStructure {
83 
84     /**
85      * URI that identifies the <code>Object</code> element (this can be
86      * specified as the value of the <code>type</code> parameter of the
87      * {@link Reference} class to identify the referent's type).
88      */
89     final static String TYPE = "http://www.w3.org/2000/09/xmldsig#Object";
90 
91     /**
92      * Returns an {@link java.util.Collections#unmodifiableList unmodifiable
93      * list} of {@link XMLStructure}s contained in this <code>XMLObject</code>,
94      * which represent elements from any namespace.
95      *
96      *<p>If there is a public subclass representing the type of
97      * <code>XMLStructure</code>, it is returned as an instance of that class
98      * (ex: a <code>SignatureProperties</code> element would be returned
99      * as an instance of {@link javax.xml.crypto.dsig.SignatureProperties}).
100      *
101      * @return an unmodifiable list of <code>XMLStructure</code>s (may be empty
102      *    but never <code>null</code>)
103      */
getContent()104     List<XMLStructure> getContent();
105 
106     /**
107      * Returns the Id of this <code>XMLObject</code>.
108      *
109      * @return the Id (or <code>null</code> if not specified)
110      */
getId()111     String getId();
112 
113     /**
114      * Returns the mime type of this <code>XMLObject</code>. The
115      * mime type is an optional attribute which describes the data within this
116      * <code>XMLObject</code> (independent of its encoding).
117      *
118      * @return the mime type (or <code>null</code> if not specified)
119      */
getMimeType()120     String getMimeType();
121 
122     /**
123      * Returns the encoding URI of this <code>XMLObject</code>. The encoding
124      * URI identifies the method by which the object is encoded.
125      *
126      * @return the encoding URI (or <code>null</code> if not specified)
127      */
getEncoding()128     String getEncoding();
129 }
130