KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xml > internal > security > signature > SignatureProperty


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17 package com.sun.org.apache.xml.internal.security.signature;
18
19 import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
20 import com.sun.org.apache.xml.internal.security.utils.Constants;
21 import com.sun.org.apache.xml.internal.security.utils.IdResolver;
22 import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
23 import org.w3c.dom.Document JavaDoc;
24 import org.w3c.dom.Element JavaDoc;
25 import org.w3c.dom.Node JavaDoc;
26
27 /**
28  * Handles <code>&lt;ds:SignatureProperty&gt;</code> elements
29  * Addittional information item concerning the generation of the signature(s) can
30  * be placed in this Element
31  *
32  * @author Christian Geuer-Pollmann
33  */

34 public class SignatureProperty extends SignatureElementProxy {
35
36    /** {@link java.util.logging} logging facility */
37     static java.util.logging.Logger JavaDoc log =
38         java.util.logging.Logger.getLogger(
39                             SignatureProperty.class.getName());
40
41    /**
42     * Constructs{@link SignatureProperty} using specified <code>Target</code> attribute
43     *
44     * @param doc the {@link Document} in which <code>XMLsignature</code> is placed
45     * @param Target the <code>Target</code> attribute references the <code>Signature</code> element to which the property applies SignatureProperty
46     */

47    public SignatureProperty(Document JavaDoc doc, String JavaDoc Target) {
48       this(doc, Target, null);
49    }
50
51    /**
52     * Constructs {@link SignatureProperty} using sepcified <code>Target</code> attribute and <code>Id</code> attribute
53     *
54     * @param doc the {@link Document} in which <code>XMLsignature</code> is placed
55     * @param Target the <code>Target</code> attribute references the <code>Signature</code> element to which the property applies
56     * @param Id the <code>Id</code> will be specified by {@link Reference#getURI} in validation
57     */

58    public SignatureProperty(Document JavaDoc doc, String JavaDoc Target, String JavaDoc Id) {
59
60       super(doc);
61
62       this.setTarget(Target);
63       this.setId(Id);
64    }
65
66    /**
67     * Constructs a {@link SignatureProperty} from an {@link Element}
68     * @param element <code>SignatureProperty</code> element
69     * @param BaseURI the URI of the resource where the XML instance was stored
70     * @throws XMLSecurityException
71     */

72    public SignatureProperty(Element JavaDoc element, String JavaDoc BaseURI)
73            throws XMLSecurityException {
74       super(element, BaseURI);
75    }
76
77    /**
78     * Sets the <code>Id</code> attribute
79     *
80     * @param Id the <code>Id</code> attribute
81     */

82    public void setId(String JavaDoc Id) {
83
84       if ((this._state == MODE_SIGN) && (Id != null)) {
85          this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
86          IdResolver.registerElementById(this._constructionElement, Id);
87       }
88    }
89
90    /**
91     * Returns the <code>Id</code> attribute
92     *
93     * @return the <code>Id</code> attribute
94     */

95    public String JavaDoc getId() {
96       return this._constructionElement.getAttributeNS(null, Constants._ATT_ID);
97    }
98
99    /**
100     * Sets the <code>Target</code> attribute
101     *
102     * @param Target the <code>Target</code> attribute
103     */

104    public void setTarget(String JavaDoc Target) {
105
106       if ((this._state == MODE_SIGN) && (Target != null)) {
107          this._constructionElement.setAttributeNS(null, Constants._ATT_TARGET, Target);
108       }
109    }
110
111    /**
112     * Returns the <code>Target</code> attribute
113     *
114     * @return the <code>Target</code> attribute
115     */

116    public String JavaDoc getTarget() {
117       return this._constructionElement.getAttributeNS(null, Constants._ATT_TARGET);
118    }
119
120    /**
121     * Method appendChild
122     *
123     * @param node
124     * @return the node in this element.
125     */

126    public Node JavaDoc appendChild(Node JavaDoc node) {
127       return this._constructionElement.appendChild(node);
128    }
129
130    /** @inheritDoc */
131    public String JavaDoc getBaseLocalName() {
132       return Constants._TAG_SIGNATUREPROPERTY;
133    }
134 }
135
Popular Tags