protected boolean existsIdentityForId(byte[] id) { for (P11ObjectIdentifier objectId : identities.keySet()) { if (objectId.matchesId(id)) { return true; } } return false; }
protected boolean existsCertForId(byte[] id) { for (P11ObjectIdentifier objectId : certificates.keySet()) { if (objectId.matchesId(id)) { return true; } } return false; }
protected boolean existsIdentityForId(byte[] id) { for (P11ObjectIdentifier objectId : identities.keySet()) { if (objectId.matchesId(id)) { return true; } } return false; }
protected boolean existsCertForId(byte[] id) { for (P11ObjectIdentifier objectId : certificates.keySet()) { if (objectId.matchesId(id)) { return true; } } return false; }
@Override public P11ObjectIdentifier getObjectIdForId(final byte[] id) { for (P11ObjectIdentifier objectId : identities.keySet()) { if (objectId.matchesId(id)) { return objectId; } } for (P11ObjectIdentifier objectId : certificates.keySet()) { if (objectId.matchesId(id)) { return objectId; } } return null; }
/** * Gets certificate with the given identifier {@code id}. * @param id * Identifier of the certificate. Must not be {@code null}. * @return certificate with the given identifier. */ protected X509Cert getCertForId(final byte[] id) { for (P11ObjectIdentifier objId : certificates.keySet()) { if (objId.matchesId(id)) { return certificates.get(objId); } } return null; }
/** * Gets certificate with the given identifier {@code id}. * @param id * Identifier of the certificate. Must not be {@code null}. * @return certificate with the given identifier. */ public X509Cert getCertForId(byte[] id) { for (P11ObjectIdentifier objId : certificates.keySet()) { if (objId.matchesId(id)) { return certificates.get(objId); } } return null; }
/** * Returns the certificate of the given identifier {@code id}. * @param id * Identifier. Must not be {@code null}. * @return the certificate of the given identifier. */ public X509Cert getCertForId(byte[] id) { for (P11ObjectIdentifier objId : certificates.keySet()) { if (objId.matchesId(id)) { return certificates.get(objId); } } return null; }
/** * Gets certificate with the given identifier {@code id}. * @param id * Identifier of the certificate. Must not be {@code null}. * @return certificate with the given identifier. */ public X509Cert getCertForId(byte[] id) { for (P11ObjectIdentifier objId : certificates.keySet()) { if (objId.matchesId(id)) { return certificates.get(objId); } } return null; }
/** * Returns the certificate of the given identifier {@code id}. * @param id * Identifier. Must not be {@code null}. * @return the certificate of the given identifier. */ public X509Cert getCertForId(byte[] id) { for (P11ObjectIdentifier objId : certificates.keySet()) { if (objId.matchesId(id)) { return certificates.get(objId); } } return null; }
/** * Returns the certificate of the given identifier {@code id}. * @param id * Identifier. Must not be {@code null}. * @return the certificate of the given identifier. */ public X509Cert getCertForId(final byte[] id) { for (P11ObjectIdentifier objId : certificates.keySet()) { if (objId.matchesId(id)) { return certificates.get(objId); } } return null; } }
protected byte[] generateId() throws P11TokenException { byte[] id = new byte[8]; while (true) { random.nextBytes(id); boolean duplicated = false; for (P11ObjectIdentifier objectId : identities.keySet()) { if (objectId.matchesId(id)) { duplicated = true; break; } } if (!duplicated) { for (P11ObjectIdentifier objectId : certificates.keySet()) { if (objectId.matchesId(id)) { duplicated = true; break; } } } if (!duplicated) { return id; } } }
/** * Returns the PKCS#11 label for certificate of the given {@code id}. * @param id * Identifier. Must not be {@code null}. * @return the label. */ public String getCertLabelForId(byte[] id) { for (P11ObjectIdentifier objId : certificates.keySet()) { if (objId.matchesId(id)) { return objId.getLabel(); } } return null; }
/** * Returns the PKCS#11 label for certificate of the given {@code id}. * @param id * Identifier. Must not be {@code null}. * @return the label. */ public String getCertLabelForId(byte[] id) { for (P11ObjectIdentifier objId : certificates.keySet()) { if (objId.matchesId(id)) { return objId.getLabel(); } } return null; }
public P11IdentityId getIdentityId(byte[] keyId, String keyLabel) { if (keyId == null && keyLabel == null) { return null; } for (P11ObjectIdentifier objectId : identities.keySet()) { boolean match = true; if (keyId != null) { match = objectId.matchesId(keyId); } if (keyLabel != null) { match = keyLabel.equals(objectId.getLabel()); } if (match) { return identities.get(objectId).getId(); } } return null; }
public P11ObjectIdentifier getObjectId(byte[] id, String label) { if (id == null && label == null) { return null; } for (P11ObjectIdentifier objectId : identities.keySet()) { boolean match = true; if (id != null) { match = objectId.matchesId(id); } if (label != null) { match = label.equals(objectId.getLabel()); } if (match) { return objectId; } } for (P11ObjectIdentifier objectId : certificates.keySet()) { boolean match = true; if (id != null) { match = objectId.matchesId(id); } if (label != null) { match = label.equals(objectId.getLabel()); } if (match) { return objectId; } } return null; }
public P11IdentityId getIdentityId(byte[] keyId, String keyLabel) { if (keyId == null && keyLabel == null) { return null; } for (P11ObjectIdentifier objectId : identities.keySet()) { boolean match = true; if (keyId != null) { match = objectId.matchesId(keyId); } if (keyLabel != null) { match = keyLabel.equals(objectId.getLabel()); } if (match) { return identities.get(objectId).getId(); } } return null; }
public P11ObjectIdentifier getObjectId(byte[] id, String label) { if (id == null && label == null) { return null; } for (P11ObjectIdentifier objectId : identities.keySet()) { boolean match = true; if (id != null) { match = objectId.matchesId(id); } if (label != null) { match = label.equals(objectId.getLabel()); } if (match) { return objectId; } } for (P11ObjectIdentifier objectId : certificates.keySet()) { boolean match = true; if (id != null) { match = objectId.matchesId(id); } if (label != null) { match = label.equals(objectId.getLabel()); } if (match) { return objectId; } } return null; }
protected void assertNoIdentityAndCert(byte[] id, String label) throws P11DuplicateEntityException { if (id == null && label == null) { return; } Set<P11ObjectIdentifier> objectIds = new HashSet<>(identities.keySet()); objectIds.addAll(certificates.keySet()); for (P11ObjectIdentifier objectId : objectIds) { boolean matchId = (id == null) ? false : objectId.matchesId(id); boolean matchLabel = (label == null) ? false : label.equals(objectId.getLabel()); if (matchId || matchLabel) { StringBuilder sb = new StringBuilder("Identity or Certificate with "); if (matchId) { sb.append("id=0x").append(Hex.encodeUpper(id)); if (matchLabel) { sb.append(" and "); } } if (matchLabel) { sb.append("label=").append(label); } sb.append(" already exists"); throw new P11DuplicateEntityException(sb.toString()); } } }
protected void assertNoIdentityAndCert(byte[] id, String label) throws P11DuplicateEntityException { if (id == null && label == null) { return; } Set<P11ObjectIdentifier> objectIds = new HashSet<>(identities.keySet()); objectIds.addAll(certificates.keySet()); for (P11ObjectIdentifier objectId : objectIds) { boolean matchId = (id == null) ? false : objectId.matchesId(id); boolean matchLabel = (label == null) ? false : label.equals(objectId.getLabel()); if (matchId || matchLabel) { StringBuilder sb = new StringBuilder("Identity or Certificate with "); if (matchId) { sb.append("id=0x").append(Hex.encodeUpper(id)); if (matchLabel) { sb.append(" and "); } } if (matchLabel) { sb.append("label=").append(label); } sb.append(" already exists"); throw new P11DuplicateEntityException(sb.toString()); } } }