/** * @see java.security.IdentityScope#removeIdentity(java.security.Identity) */ public synchronized void removeIdentity(Identity identity) throws KeyManagementException { //Exception caught = null; if (identity == null) { throw new NullPointerException("identity == null"); } String name = identity.getName(); if (name == null) { throw new NullPointerException("name == null"); } boolean contains = names.containsKey(name); names.remove(name); PublicKey key = identity.getPublicKey(); if (key != null) { contains = contains || keys.containsKey(key); keys.remove(key); } if (!contains) { throw new KeyManagementException("identity not found"); } }
/** * Compares the specified {@code Identity} with this {@code Identity} for * equality and returns {@code true} if the specified object is equal, * {@code false} otherwise. * <p> * To be equal, two {@code Identity} objects need to have the same name and * the same public keys. * * @param identity * the identity to check for equality. * @return {@code true} if the {@code Identity} objects are equal, {@code * false} otherwise. */ protected boolean identityEquals(Identity identity) { if (!name.equals(identity.name)) { return false; } if (publicKey == null) { return (identity.publicKey == null); } return checkKeysEqual(publicKey, identity.publicKey); }
/** * Compares the specified object with this {@code Identity} for equality and * returns {@code true} if the specified object is equal, {@code false} * otherwise. {@code Identity} objects are considered equal, if they have * the same name and are in the same scope. * * @param obj * object to be compared for equality with this {@code * Identity}. * @return {@code true} if the specified object is equal to this {@code * Identity}, otherwise {@code false}. */ @Override public final boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Identity)) { return false; } Identity i = (Identity) obj; if (Objects.equal(name, i.name) && (Objects.equal(scope, i.scope))) { return true; } return identityEquals(i); }
/** * Returns a string containing a concise, human-readable description of the * this {@code Identity}. * * @param detailed * whether or not this method should return detailed information. * @return a printable representation for this {@code Permission}. */ public String toString(boolean detailed) { String s = toString(); if (detailed) { s += " " + info; } return s; }
/** * @deprecated */ public boolean isCallerInRole(Identity identity) { // THis method is deprecated. // This implementation is as in EJB2.0 section 21.2.5 return isCallerInRole(identity.getName()); }
/** * Returns a string containing a concise, human-readable description of this * {@code IdentityScope}. * * @return a printable representation for this {@code IdentityScope}. */ @Override public String toString() { return new StringBuilder(super.toString()) .append("[").append(size()).append("]").toString(); } }
/** * @deprecated */ public boolean isCallerInRole(Identity identity) { // THis method is deprecated. // This implementation is as in EJB2.0 section 21.2.5 return isCallerInRole(identity.getName()); }
/** * @see java.security.IdentityScope#addIdentity(java.security.Identity) */ public synchronized void addIdentity(Identity identity) throws KeyManagementException { if (identity == null) { throw new NullPointerException("identity == null"); } String name = identity.getName(); if (names.containsKey(name)) { throw new KeyManagementException("name '" + name + "' is already used"); } PublicKey key = identity.getPublicKey(); if (key != null && keys.containsKey(key)) { throw new KeyManagementException("key '" + key + "' is already used"); } names.put(name, identity); if (key != null) { keys.put(key, identity); } }
/** * Returns a string containing a concise, human-readable description of the * this {@code Identity}. * * @param detailed * whether or not this method should return detailed information. * @return a printable representation for this {@code Permission}. */ public String toString(boolean detailed) { String s = toString(); if (detailed) { s += " " + info; } return s; }
/** * Adds a {@code Certificate} to this {@code Identity}. * * @param certificate * the {@code Certificate} to be added to this {@code Identity}. * @throws KeyManagementException * if the certificate is not valid. */ public void addCertificate(Certificate certificate) throws KeyManagementException { PublicKey certPK = certificate.getPublicKey(); if (publicKey != null) { if (!checkKeysEqual(publicKey, certPK)) { throw new KeyManagementException("Cert's public key does not match Identity's public key"); } } else { publicKey = certPK; } if (certificates == null) { certificates = new Vector<Certificate>(); } certificates.add(certificate); }
/** * Compares the specified object with this {@code Identity} for equality and * returns {@code true} if the specified object is equal, {@code false} * otherwise. {@code Identity} objects are considered equal, if they have * the same name and are in the same scope. * * @param obj * object to be compared for equality with this {@code * Identity}. * @return {@code true} if the specified object is equal to this {@code * Identity}, otherwise {@code false}. */ @Override public final boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Identity)) { return false; } Identity i = (Identity) obj; if (Objects.equal(name, i.name) && (Objects.equal(scope, i.scope))) { return true; } return identityEquals(i); }
Identity identity = injector.getInstance(Identity.class); Authentication auth = new Authentication(); Identity authenticated = auth.authenticate("login","password"); identity.setUid(authenticated.getUid()); identity.setName(authenticated.getName());
/** * @see java.security.IdentityScope#removeIdentity(java.security.Identity) */ public synchronized void removeIdentity(Identity identity) throws KeyManagementException { //Exception caught = null; if (identity == null) { throw new NullPointerException("identity == null"); } String name = identity.getName(); if (name == null) { throw new NullPointerException("name == null"); } boolean contains = names.containsKey(name); names.remove(name); PublicKey key = identity.getPublicKey(); if (key != null) { contains = contains || keys.containsKey(key); keys.remove(key); } if (!contains) { throw new KeyManagementException("identity not found"); } }
/** * Returns a string containing a concise, human-readable description of the * this {@code Identity}. * * @param detailed * whether or not this method should return detailed information. * @return a printable representation for this {@code Permission}. */ public String toString(boolean detailed) { String s = toString(); if (detailed) { s += " " + info; } return s; }
/** * Compares the specified {@code Identity} with this {@code Identity} for * equality and returns {@code true} if the specified object is equal, * {@code false} otherwise. * <p> * To be equal, two {@code Identity} objects need to have the same name and * the same public keys. * * @param identity * the identity to check for equality. * @return {@code true} if the {@code Identity} objects are equal, {@code * false} otherwise. */ protected boolean identityEquals(Identity identity) { if (!name.equals(identity.name)) { return false; } if (publicKey == null) { return (identity.publicKey == null); } return checkKeysEqual(publicKey, identity.publicKey); }
/** * Compares the specified object with this {@code Identity} for equality and * returns {@code true} if the specified object is equal, {@code false} * otherwise. {@code Identity} objects are considered equal, if they have * the same name and are in the same scope. * * @param obj * object to be compared for equality with this {@code * Identity}. * @return {@code true} if the specified object is equal to this {@code * Identity}, otherwise {@code false}. */ @Override public final boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Identity)) { return false; } Identity i = (Identity) obj; if (Objects.equal(name, i.name) && (Objects.equal(scope, i.scope))) { return true; } return identityEquals(i); }
/** * @see java.security.IdentityScope#removeIdentity(java.security.Identity) */ public synchronized void removeIdentity(Identity identity) throws KeyManagementException { //Exception caught = null; if (identity == null) { throw new NullPointerException("identity == null"); } String name = identity.getName(); if (name == null) { throw new NullPointerException("name == null"); } boolean contains = names.containsKey(name); names.remove(name); PublicKey key = identity.getPublicKey(); if (key != null) { contains = contains || keys.containsKey(key); keys.remove(key); } if (!contains) { throw new KeyManagementException("identity not found"); } }
/** * Returns a string containing a concise, human-readable description of the * this {@code Identity}. * * @param detailed * whether or not this method should return detailed information. * @return a printable representation for this {@code Permission}. */ public String toString(boolean detailed) { String s = toString(); if (detailed) { s += " " + info; } return s; }
/** * Compares the specified {@code Identity} with this {@code Identity} for * equality and returns {@code true} if the specified object is equal, * {@code false} otherwise. * <p> * To be equal, two {@code Identity} objects need to have the same name and * the same public keys. * * @param identity * the identity to check for equality. * @return {@code true} if the {@code Identity} objects are equal, {@code * false} otherwise. */ protected boolean identityEquals(Identity identity) { if (!name.equals(identity.name)) { return false; } if (publicKey == null) { return (identity.publicKey == null); } return checkKeysEqual(publicKey, identity.publicKey); }
/** * Compares the specified object with this {@code Identity} for equality and * returns {@code true} if the specified object is equal, {@code false} * otherwise. {@code Identity} objects are considered equal, if they have * the same name and are in the same scope. * * @param obj * object to be compared for equality with this {@code * Identity}. * @return {@code true} if the specified object is equal to this {@code * Identity}, otherwise {@code false}. */ @Override public final boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Identity)) { return false; } Identity i = (Identity) obj; if (Objects.equal(name, i.name) && (Objects.equal(scope, i.scope))) { return true; } return identityEquals(i); }