home *** CD-ROM | disk | FTP | other *** search
- package java.security;
-
- import java.io.Serializable;
- import java.util.Enumeration;
- import java.util.Vector;
-
- public abstract class Identity implements Principal, Serializable {
- private String name;
- private PublicKey publicKey;
- String info;
- IdentityScope scope;
- Vector certificates;
-
- protected Identity() {
- this("restoring...");
- }
-
- public Identity(String var1, IdentityScope var2) throws KeyManagementException {
- this(var1);
- this.scope = var2;
- }
-
- public Identity(String var1) {
- this.info = "No further information available.";
- this.name = var1;
- }
-
- public final String getName() {
- return this.name;
- }
-
- public final IdentityScope getScope() {
- return this.scope;
- }
-
- public PublicKey getPublicKey() {
- return this.publicKey;
- }
-
- public void setPublicKey(PublicKey var1) throws KeyManagementException {
- this.check("set.public.key");
- this.publicKey = var1;
- this.certificates = new Vector();
- }
-
- public void setInfo(String var1) {
- this.check("set.info");
- this.info = var1;
- }
-
- public String getInfo() {
- return this.info;
- }
-
- public void addCertificate(Certificate var1) throws KeyManagementException {
- this.check("add.certificate");
- if (this.certificates == null) {
- this.certificates = new Vector();
- }
-
- if (this.publicKey != null) {
- if (!this.keyEquals(this.publicKey, var1.getPublicKey())) {
- throw new KeyManagementException("public key different from cert public key");
- }
- } else {
- this.publicKey = var1.getPublicKey();
- }
-
- this.certificates.addElement(var1);
- }
-
- private boolean keyEquals(Key var1, Key var2) {
- return var1.getFormat().equalsIgnoreCase(var2.getFormat()) ? MessageDigest.isEqual(var1.getEncoded(), var2.getEncoded()) : false;
- }
-
- public void removeCertificate(Certificate var1) throws KeyManagementException {
- this.check("remove.certificate");
- if (this.certificates != null) {
- this.certificates.removeElement(var1);
- }
-
- }
-
- public Certificate[] certificates() {
- if (this.certificates == null) {
- return new Certificate[0];
- } else {
- int var1 = this.certificates.size();
- Certificate[] var2 = new Certificate[var1];
- this.certificates.copyInto(var2);
- return var2;
- }
- }
-
- public final boolean equals(Object var1) {
- if (var1 == this) {
- return true;
- } else if (var1 instanceof Identity) {
- Identity var2 = (Identity)var1;
- return var2.getScope() == this.scope && var2.getName().equals(this.name) ? true : this.identityEquals(var2);
- } else {
- return false;
- }
- }
-
- protected boolean identityEquals(Identity var1) {
- return this.name.equals(var1.name) && this.publicKey.equals(var1.publicKey);
- }
-
- String fullName() {
- String var1 = this.name;
- if (this.scope != null) {
- var1 = var1 + "." + this.scope.getName();
- }
-
- return var1;
- }
-
- public String toString() {
- this.check("print");
- String var1 = this.name;
- if (this.scope != null) {
- var1 = var1 + "[" + this.scope.getName() + "]";
- }
-
- return var1;
- }
-
- public String toString(boolean var1) {
- String var2 = this.toString();
- if (var1) {
- var2 = var2 + "\n";
- var2 = var2 + this.printKeys();
- var2 = var2 + "\n" + this.printCertificates();
- if (this.info != null) {
- var2 = var2 + "\n\t" + this.info;
- } else {
- var2 = var2 + "\n\tno additional information available.";
- }
- }
-
- return var2;
- }
-
- String printKeys() {
- String var1 = "";
- if (this.publicKey != null) {
- var1 = "\tpublic key initialized";
- } else {
- var1 = "\tno public key";
- }
-
- return var1;
- }
-
- String printCertificates() {
- String var1 = "";
- if (this.certificates == null) {
- return "\tno certificates";
- } else {
- var1 = var1 + "\tcertificates: \n";
- Enumeration var2 = this.certificates.elements();
-
- Certificate var4;
- for(int var3 = 1; var2.hasMoreElements(); var1 = var1 + "\t\t\tfrom : " + var4.getGuarantor() + "\n") {
- var4 = (Certificate)var2.nextElement();
- var1 = var1 + "\tcertificate " + var3++ + "\tfor : " + var4.getPrincipal() + "\n";
- }
-
- return var1;
- }
- }
-
- public int hashCode() {
- String var1 = this.name;
- if (this.scope != null) {
- var1 = var1 + this.scope.getName();
- }
-
- return var1.hashCode();
- }
-
- void check(String var1) {
- staticCheck(this.getClass().getName() + "." + var1 + "." + this.fullName());
- }
-
- static void staticCheck(String var0) {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkSecurityAccess(var0);
- }
-
- }
- }
-