1 /* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5 /* 6 * Copyright 1999-2004 The Apache Software Foundation. 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 * 20 */ 21 package com.sun.org.apache.xml.internal.security.signature; 22 23 import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; 24 import com.sun.org.apache.xml.internal.security.utils.Constants; 25 import com.sun.org.apache.xml.internal.security.utils.IdResolver; 26 import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy; 27 import org.w3c.dom.Document; 28 import org.w3c.dom.Element; 29 import org.w3c.dom.Node; 30 31 /** 32 * Handles <code><ds:SignatureProperty></code> elements 33 * Additional information item concerning the generation of the signature(s) can 34 * be placed in this Element 35 * 36 * @author Christian Geuer-Pollmann 37 */ 38 public class SignatureProperty extends SignatureElementProxy { 39 40 /** 41 * Constructs{@link SignatureProperty} using specified <code>Target</code> attribute 42 * 43 * @param doc the {@link Document} in which <code>XMLsignature</code> is placed 44 * @param Target the <code>Target</code> attribute references the <code>Signature</code> element to which the property applies SignatureProperty 45 */ 46 public SignatureProperty(Document doc, String Target) { 47 this(doc, Target, null); 48 } 49 50 /** 51 * Constructs {@link SignatureProperty} using sepcified <code>Target</code> attribute and <code>Id</code> attribute 52 * 53 * @param doc the {@link Document} in which <code>XMLsignature</code> is placed 54 * @param Target the <code>Target</code> attribute references the <code>Signature</code> element to which the property applies 55 * @param Id the <code>Id</code> will be specified by {@link Reference#getURI} in validation 56 */ 57 public SignatureProperty(Document doc, String Target, String Id) { 58 59 super(doc); 60 61 this.setTarget(Target); 62 this.setId(Id); 63 } 64 65 /** 66 * Constructs a {@link SignatureProperty} from an {@link Element} 67 * @param element <code>SignatureProperty</code> element 68 * @param BaseURI the URI of the resource where the XML instance was stored 69 * @throws XMLSecurityException 70 */ 71 public SignatureProperty(Element element, String BaseURI) 72 throws XMLSecurityException { 73 super(element, BaseURI); 74 } 75 76 /** 77 * Sets the <code>Id</code> attribute 78 * 79 * @param Id the <code>Id</code> attribute 80 */ 81 public void setId(String Id) { 82 83 if (Id != null) { 84 setLocalIdAttribute(Constants._ATT_ID, Id); 85 } 86 } 87 88 /** 89 * Returns the <code>Id</code> attribute 90 * 91 * @return the <code>Id</code> attribute 92 */ 93 public String getId() { 94 return this._constructionElement.getAttributeNS(null, Constants._ATT_ID); 95 } 96 97 /** 98 * Sets the <code>Target</code> attribute 99 * 100 * @param Target the <code>Target</code> attribute 101 */ 102 public void setTarget(String Target) { 103 104 if ((Target != null)) { 105 this._constructionElement.setAttributeNS(null, Constants._ATT_TARGET, Target); 106 } 107 } 108 109 /** 110 * Returns the <code>Target</code> attribute 111 * 112 * @return the <code>Target</code> attribute 113 */ 114 public String getTarget() { 115 return this._constructionElement.getAttributeNS(null, Constants._ATT_TARGET); 116 } 117 118 /** 119 * Method appendChild 120 * 121 * @param node 122 * @return the node in this element. 123 */ 124 public Node appendChild(Node node) { 125 return this._constructionElement.appendChild(node); 126 } 127 128 /** @inheritDoc */ 129 public String getBaseLocalName() { 130 return Constants._TAG_SIGNATUREPROPERTY; 131 } 132 }