Method from java.security.Identity Detail: |
public void addCertificate(Certificate certificate) throws KeyManagementException {
check("addIdentityCertificate");
if (certificates == null) {
certificates = new Vector< Certificate >();
}
if (publicKey != null) {
if (!keyEquals(publicKey, certificate.getPublicKey())) {
throw new KeyManagementException(
"public key different from cert public key");
}
} else {
publicKey = certificate.getPublicKey();
}
certificates.addElement(certificate);
} Deprecated!Adds a certificate for this identity. If the identity has a public
key, the public key in the certificate must be the same, and if
the identity does not have a public key, the identity's
public key is set to be that specified in the certificate.
First, if there is a security manager, its checkSecurityAccess
method is called with "addIdentityCertificate"
as its argument to see if it's ok to add a certificate. |
public Certificate[] certificates() {
if (certificates == null) {
return new Certificate[0];
}
int len = certificates.size();
Certificate[] certs = new Certificate[len];
certificates.copyInto(certs);
return certs;
} Deprecated!Returns a copy of all the certificates for this identity. |
public final boolean equals(Object identity) {
if (identity == this) {
return true;
}
if (identity instanceof Identity) {
Identity i = (Identity)identity;
if (this.fullName().equals(i.fullName())) {
return true;
} else {
return identityEquals(i);
}
}
return false;
} Deprecated!Tests for equality between the specified object and this identity.
This first tests to see if the entities actually refer to the same
object, in which case it returns true. Next, it checks to see if
the entities have the same name and the same scope. If they do,
the method returns true. Otherwise, it calls
identityEquals , which subclasses should
override. |
String fullName() {
String parsable = name;
if (scope != null) {
parsable += "." + scope.getName();
}
return parsable;
} Deprecated!Returns a parsable name for identity: identityName.scopeName |
public String getInfo() {
return info;
} Deprecated!Returns general information previously specified for this identity. |
public final String getName() {
return name;
} Deprecated!Returns this identity's name. |
public PublicKey getPublicKey() {
return publicKey;
} Deprecated!Returns this identity's public key. |
public final IdentityScope getScope() {
return scope;
} Deprecated!Returns this identity's scope. |
public int hashCode() {
return name.hashCode();
} Deprecated!Returns a hashcode for this identity. |
protected boolean identityEquals(Identity identity) {
if (!name.equalsIgnoreCase(identity.name))
return false;
if ((publicKey == null) ^ (identity.publicKey == null))
return false;
if (publicKey != null && identity.publicKey != null)
if (!publicKey.equals(identity.publicKey))
return false;
return true;
} Deprecated!Tests for equality between the specified identity and this identity.
This method should be overriden by subclasses to test for equality.
The default behavior is to return true if the names and public keys
are equal. |
String printCertificates() {
String out = "";
if (certificates == null) {
return "\tno certificates";
} else {
out += "\tcertificates: \n";
int i = 1;
for (Certificate cert : certificates) {
out += "\tcertificate " + i++ +
"\tfor : " + cert.getPrincipal() + "\n";
out += "\t\t\tfrom : " +
cert.getGuarantor() + "\n";
}
}
return out;
} Deprecated! |
String printKeys() {
String key = "";
if (publicKey != null) {
key = "\tpublic key initialized";
} else {
key = "\tno public key";
}
return key;
} Deprecated! |
public void removeCertificate(Certificate certificate) throws KeyManagementException {
check("removeIdentityCertificate");
if (certificates != null) {
certificates.removeElement(certificate);
}
} Deprecated!Removes a certificate from this identity.
First, if there is a security manager, its checkSecurityAccess
method is called with "removeIdentityCertificate"
as its argument to see if it's ok to remove a certificate. |
public void setInfo(String info) {
check("setIdentityInfo");
this.info = info;
} Deprecated!Specifies a general information string for this identity.
First, if there is a security manager, its checkSecurityAccess
method is called with "setIdentityInfo"
as its argument to see if it's ok to specify the information string. |
public void setPublicKey(PublicKey key) throws KeyManagementException {
check("setIdentityPublicKey");
this.publicKey = key;
certificates = new Vector< Certificate >();
} Deprecated!Sets this identity's public key. The old key and all of this
identity's certificates are removed by this operation.
First, if there is a security manager, its checkSecurityAccess
method is called with "setIdentityPublicKey"
as its argument to see if it's ok to set the public key. |
public String toString() {
check("printIdentity");
String printable = name;
if (scope != null) {
printable += "[" + scope.getName() + "]";
}
return printable;
} Deprecated!Returns a short string describing this identity, telling its
name and its scope (if any).
First, if there is a security manager, its checkSecurityAccess
method is called with "printIdentity"
as its argument to see if it's ok to return the string. |
public String toString(boolean detailed) {
String out = toString();
if (detailed) {
out += "\n";
out += printKeys();
out += "\n" + printCertificates();
if (info != null) {
out += "\n\t" + info;
} else {
out += "\n\tno additional information available.";
}
}
return out;
} Deprecated!Returns a string representation of this identity, with
optionally more details than that provided by the
toString method without any arguments.
First, if there is a security manager, its checkSecurityAccess
method is called with "printIdentity"
as its argument to see if it's ok to return the string. |