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 /**
  34  * Handles <code>&lt;ds:Object&gt;</code> elements
  35  * <code>Object<code> {@link Element} supply facility which can contain any kind data
  36  *
  37  * @author Christian Geuer-Pollmann
  38  * $todo$ if we remove childen, the boolean values are not updated
  39  */
  40 public class ObjectContainer extends SignatureElementProxy {
  41 
  42     /**
  43      * Constructs {@link ObjectContainer}
  44      *
  45      * @param doc the {@link Document} in which <code>Object</code> element is placed
  46      */
  47     public ObjectContainer(Document doc) {
  48         super(doc);
  49     }
  50 
  51     /**
  52      * Constructs {@link ObjectContainer} from {@link Element}
  53      *
  54      * @param element is <code>Object</code> element
  55      * @param baseURI the URI of the resource where the XML instance was stored
  56      * @throws XMLSecurityException
  57      */
  58     public ObjectContainer(Element element, String baseURI) throws XMLSecurityException {
  59         super(element, baseURI);
  60     }
  61 
  62     /**
  63      * Sets the <code>Id</code> attribute
  64      *
  65      * @param Id <code>Id</code> attribute
  66      */
  67     public void setId(String Id) {
  68         if (Id != null) {
  69             this.constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
  70             this.constructionElement.setIdAttributeNS(null, Constants._ATT_ID, true);
  71         }
  72     }
  73 
  74     /**
  75      * Returns the <code>Id</code> attribute
  76      *
  77      * @return the <code>Id</code> attribute
  78      */
  79     public String getId() {
  80         return this.constructionElement.getAttributeNS(null, Constants._ATT_ID);
  81     }
  82 
  83     /**
  84      * Sets the <code>MimeType</code> attribute
  85      *
  86      * @param MimeType the <code>MimeType</code> attribute
  87      */
  88     public void setMimeType(String MimeType) {
  89         if (MimeType != null) {
  90             this.constructionElement.setAttributeNS(null, Constants._ATT_MIMETYPE, MimeType);
  91         }
  92     }
  93 
  94     /**
  95      * Returns the <code>MimeType</code> attribute
  96      *
  97      * @return the <code>MimeType</code> attribute
  98      */
  99     public String getMimeType() {
 100         return this.constructionElement.getAttributeNS(null, Constants._ATT_MIMETYPE);
 101     }
 102 
 103     /**
 104      * Sets the <code>Encoding</code> attribute
 105      *
 106      * @param Encoding the <code>Encoding</code> attribute
 107      */
 108     public void setEncoding(String Encoding) {
 109         if (Encoding != null) {
 110             this.constructionElement.setAttributeNS(null, Constants._ATT_ENCODING, Encoding);
 111         }
 112     }
 113 
 114     /**
 115      * Returns the <code>Encoding</code> attribute
 116      *
 117      * @return the <code>Encoding</code> attribute
 118      */
 119     public String getEncoding() {
 120         return this.constructionElement.getAttributeNS(null, Constants._ATT_ENCODING);
 121     }
 122 
 123     /**
 124      * Adds child Node
 125      *
 126      * @param node child Node
 127      * @return the new node in the tree.
 128      */
 129     public Node appendChild(Node node) {
 130         return this.constructionElement.appendChild(node);
 131     }
 132 
 133     /** @inheritDoc */
 134     public String getBaseLocalName() {
 135         return Constants._TAG_OBJECT;
 136     }
 137 }