src/share/classes/com/sun/org/apache/xml/internal/security/signature/SignatureProperty.java

Print this page


   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>&lt;ds:SignatureProperty&gt;</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 }
   1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /**
   6  * Licensed to the Apache Software Foundation (ASF) under one
   7  * or more contributor license agreements. See the NOTICE file
   8  * distributed with this work for additional information
   9  * regarding copyright ownership. The ASF licenses this file
  10  * to you under the Apache License, Version 2.0 (the
  11  * "License"); you may not use this file except in compliance
  12  * with the License. You may obtain a copy of the License at
  13  *
  14  * http://www.apache.org/licenses/LICENSE-2.0
  15  *
  16  * Unless required by applicable law or agreed to in writing,
  17  * software distributed under the License is distributed on an
  18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  19  * KIND, either express or implied. See the License for the
  20  * specific language governing permissions and limitations
  21  * under the License.
  22  */
  23 package com.sun.org.apache.xml.internal.security.signature;
  24 
  25 import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
  26 import com.sun.org.apache.xml.internal.security.utils.Constants;

  27 import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
  28 import org.w3c.dom.Document;
  29 import org.w3c.dom.Element;
  30 import org.w3c.dom.Node;
  31 
  32 /**
  33  * Handles <code>&lt;ds:SignatureProperty&gt;</code> elements
  34  * Additional information item concerning the generation of the signature(s) can
  35  * be placed in this Element
  36  *
  37  * @author Christian Geuer-Pollmann
  38  */
  39 public class SignatureProperty extends SignatureElementProxy {
  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> 
  46      * element to which the property applies SignatureProperty
  47      */
  48     public SignatureProperty(Document doc, String target) {
  49         this(doc, target, null);
  50     }
  51 
  52     /**
  53      * Constructs {@link SignatureProperty} using sepcified <code>target</code> attribute and 
  54      * <code>id</code> attribute
  55      *
  56      * @param doc the {@link Document} in which <code>XMLsignature</code> is placed
  57      * @param target the <code>target</code> attribute references the <code>Signature</code>
  58      *  element to which the property applies
  59      * @param id the <code>id</code> will be specified by {@link Reference#getURI} in validation
  60      */
  61     public SignatureProperty(Document doc, String target, String id) {

  62         super(doc);
  63 
  64         this.setTarget(target);
  65         this.setId(id);
  66     }
  67 
  68     /**
  69      * Constructs a {@link SignatureProperty} from an {@link Element}
  70      * @param element <code>SignatureProperty</code> element
  71      * @param BaseURI the URI of the resource where the XML instance was stored
  72      * @throws XMLSecurityException
  73      */
  74     public SignatureProperty(Element element, String BaseURI) throws XMLSecurityException {

  75         super(element, BaseURI);
  76     }
  77 
  78     /**
  79      *   Sets the <code>id</code> attribute
  80      *
  81      *   @param id the <code>id</code> attribute
  82      */
  83     public void setId(String id) {
  84         if (id != null) {
  85             this.constructionElement.setAttributeNS(null, Constants._ATT_ID, id);
  86             this.constructionElement.setIdAttributeNS(null, Constants._ATT_ID, true);
  87         }
  88     }
  89 
  90     /**
  91      * Returns the <code>id</code> attribute
  92      *
  93      * @return the <code>id</code> attribute
  94      */
  95     public String 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 target) {
 105         if (target != null) {
 106             this.constructionElement.setAttributeNS(null, Constants._ATT_TARGET, target);

 107         }
 108     }
 109 
 110     /**
 111      * Returns the <code>target</code> attribute
 112      *
 113      * @return the <code>target</code> attribute
 114      */
 115     public String getTarget() {
 116         return this.constructionElement.getAttributeNS(null, Constants._ATT_TARGET);
 117     }
 118 
 119     /**
 120      * Method appendChild
 121      *
 122      * @param node
 123      * @return the node in this element.
 124      */
 125     public Node appendChild(Node node) {
 126         return this.constructionElement.appendChild(node);
 127     }
 128 
 129     /** @inheritDoc */
 130     public String getBaseLocalName() {
 131         return Constants._TAG_SIGNATUREPROPERTY;
 132     }
 133 }