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 */
23package com.sun.org.apache.xml.internal.security.keys.content;
24
25import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
26import com.sun.org.apache.xml.internal.security.utils.Constants;
27import com.sun.org.apache.xml.internal.security.utils.Signature11ElementProxy;
28import org.w3c.dom.Attr;
29import org.w3c.dom.Document;
30import org.w3c.dom.Element;
31
32/**
33 * Provides content model support for the <code>dsig11:KeyInfoReference</code> element.
34 *
35 * @author Brent Putman (putmanb@georgetown.edu)
36 */
37public class KeyInfoReference extends Signature11ElementProxy implements KeyInfoContent {
38
39    /**
40     * Constructor RetrievalMethod
41     *
42     * @param element
43     * @param BaseURI
44     * @throws XMLSecurityException
45     */
46    public KeyInfoReference(Element element, String baseURI) throws XMLSecurityException {
47        super(element, baseURI);
48    }
49
50    /**
51     * Constructor RetrievalMethod
52     *
53     * @param doc
54     * @param URI
55     */
56    public KeyInfoReference(Document doc, String URI) {
57        super(doc);
58
59        this.constructionElement.setAttributeNS(null, Constants._ATT_URI, URI);
60    }
61
62    /**
63     * Method getURIAttr
64     *
65     * @return the URI attribute
66     */
67    public Attr getURIAttr() {
68        return this.constructionElement.getAttributeNodeNS(null, Constants._ATT_URI);
69    }
70
71    /**
72     * Method getURI
73     *
74     * @return URI string
75     */
76    public String getURI() {
77        return this.getURIAttr().getNodeValue();
78    }
79
80    /**
81     * Sets the <code>Id</code> attribute
82     *
83     * @param Id ID
84     */
85    public void setId(String id) {
86        if (id != null) {
87            this.constructionElement.setAttributeNS(null, Constants._ATT_ID, id);
88            this.constructionElement.setIdAttributeNS(null, Constants._ATT_ID, true);
89        } else {
90            this.constructionElement.removeAttributeNS(null, Constants._ATT_ID);
91        }
92    }
93
94    /**
95     * Returns the <code>Id</code> attribute
96     *
97     * @return the <code>Id</code> attribute
98     */
99    public String getId() {
100        return this.constructionElement.getAttributeNS(null, Constants._ATT_ID);
101    }
102
103    /** @inheritDoc */
104    public String getBaseLocalName() {
105        return Constants._TAG_KEYINFOREFERENCE;
106    }
107}
108