1 23 24 package com.sun.enterprise.security.auth.login; 25 26 import java.security.cert.X509Certificate ; 27 28 33 34 public class X509CertificateCredential { 35 private X509Certificate [] certChain; 36 private String realm; 37 private String alias; 38 39 46 47 public X509CertificateCredential(X509Certificate [] certChain, 48 String alias, String realm) 49 { 50 this.certChain = certChain; 51 this.alias = alias; 52 this.realm = realm; 53 } 54 55 59 public String getAlias() { 60 return alias; 61 } 62 63 67 public String getRealm() { 68 return realm; 69 } 70 71 75 public X509Certificate [] getX509CertificateChain() { 76 return certChain; 77 } 78 79 84 public boolean equals(Object o) { 85 if(o instanceof X509CertificateCredential) { 86 X509CertificateCredential pc = (X509CertificateCredential) o; 87 if(pc.getRealm().equals(realm) && pc.getAlias().equals(alias)) { 88 X509Certificate [] certs = pc.getX509CertificateChain(); 89 for(int i = 0; i < certs.length; i++) { 90 if(!certs[i].equals(certChain[i])) { 91 return false; 92 } 93 } 94 return true; 95 } 96 } 97 return false; 98 } 99 100 104 public int hashCode() { 105 return certChain.hashCode() + realm.hashCode() + alias.hashCode(); 106 } 107 108 111 public String toString() { 112 String s = "Realm=" + realm; 113 s = s + " alias=" + alias; 114 s = s + " X509Certificate=" + certChain; 115 return s; 116 } 117 118 } 119 | Popular Tags |