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.keys.content.x509; 22 23 import java.security.cert.X509Certificate; 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.RFC2253Parser; 28 import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy; 29 import org.w3c.dom.Document; 30 import org.w3c.dom.Element; 31 32 /** 33 * 34 * @author $Author: mullan $ 35 */ 36 public class XMLX509SubjectName extends SignatureElementProxy 37 implements XMLX509DataContent { 38 39 /** 40 * Constructor X509SubjectName 41 * 42 * @param element 43 * @param BaseURI 44 * @throws XMLSecurityException 45 */ 46 public XMLX509SubjectName(Element element, String BaseURI) 47 throws XMLSecurityException { 48 super(element, BaseURI); 49 } 50 51 /** 52 * Constructor X509SubjectName 53 * 54 * @param doc 55 * @param X509SubjectNameString 56 */ 57 public XMLX509SubjectName(Document doc, String X509SubjectNameString) { 58 59 super(doc); 60 61 this.addText(X509SubjectNameString); 62 } 63 64 /** 65 * Constructor XMLX509SubjectName 66 * 67 * @param doc 68 * @param x509certificate 69 */ 70 public XMLX509SubjectName(Document doc, X509Certificate x509certificate) { 71 this(doc, 72 RFC2253Parser.normalize(x509certificate.getSubjectDN().getName())); 73 } 74 75 /** 76 * Method getSubjectName 77 * 78 * 79 * @return the subject name 80 */ 81 public String getSubjectName() { 82 return RFC2253Parser.normalize(this.getTextFromTextChild()); 83 } 84 85 /** @inheritDoc */ 86 public boolean equals(Object obj) { 87 if (obj == null) { 88 return false; 89 } 90 91 if (!this.getClass().getName().equals(obj.getClass().getName())) { 92 return false; 93 } 94 95 XMLX509SubjectName other = (XMLX509SubjectName) obj; 96 String otherSubject = other.getSubjectName(); 97 String thisSubject = this.getSubjectName(); 98 99 return thisSubject.equals(otherSubject); 100 } 101 102 /** @inheritDoc */ 103 public String getBaseLocalName() { 104 return Constants._TAG_X509SUBJECTNAME; 105 } 106 }