KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xml > internal > security > keys > content > x509 > XMLX509SubjectName


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.keys.content.x509;
18
19
20
21 import java.security.cert.X509Certificate JavaDoc;
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.RFC2253Parser;
26 import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
27 import org.w3c.dom.Document JavaDoc;
28 import org.w3c.dom.Element JavaDoc;
29
30 /**
31  *
32  * @author $Author: raul $
33  */

34 public class XMLX509SubjectName extends SignatureElementProxy
35         implements XMLX509DataContent {
36
37    /** {@link java.util.logging} logging facility */
38     static java.util.logging.Logger JavaDoc log =
39         java.util.logging.Logger.getLogger(XMLX509SubjectName.class.getName());
40
41    /**
42     * Constructor X509SubjectName
43     *
44     * @param element
45     * @param BaseURI
46     * @throws XMLSecurityException
47     */

48    public XMLX509SubjectName(Element JavaDoc element, String JavaDoc BaseURI)
49            throws XMLSecurityException {
50       super(element, BaseURI);
51    }
52
53    /**
54     * Constructor X509SubjectName
55     *
56     * @param doc
57     * @param X509SubjectNameString
58     */

59    public XMLX509SubjectName(Document JavaDoc doc, String JavaDoc X509SubjectNameString) {
60
61       super(doc);
62
63       this.addText(X509SubjectNameString);
64    }
65
66    /**
67     * Constructor XMLX509SubjectName
68     *
69     * @param doc
70     * @param x509certificate
71     */

72    public XMLX509SubjectName(Document JavaDoc doc, X509Certificate JavaDoc x509certificate) {
73       this(doc,
74            RFC2253Parser.normalize(x509certificate.getSubjectDN().getName()));
75    }
76
77    /**
78     * Method getSubjectName
79     *
80     *
81     * @return the subject name
82     */

83    public String JavaDoc getSubjectName() {
84       return RFC2253Parser.normalize(this.getTextFromTextChild());
85    }
86
87    /** @inheritDoc */
88    public boolean equals(Object JavaDoc obj) {
89
90       if (!obj.getClass().getName().equals(this.getClass().getName())) {
91          return false;
92       }
93
94       XMLX509SubjectName other = (XMLX509SubjectName) obj;
95       String JavaDoc otherSubject = other.getSubjectName();
96       String JavaDoc thisSubject = this.getSubjectName();
97
98       if (otherSubject.equals(thisSubject)) {
99             return true;
100       }
101
102        return false;
103       
104    }
105    
106    /** @inheritDoc */
107    public String JavaDoc getBaseLocalName() {
108       return Constants._TAG_X509SUBJECTNAME;
109    }
110 }
111
Popular Tags