ProxyP11Identity(ProxyP11Slot slot, P11IdentityId identityId, PublicKey publicKey, X509Certificate[] certificateChain) { super(slot, identityId, publicKey, certificateChain); this.asn1KeyId = new ProxyMessage.ObjectIdentifier(identityId.getKeyId()); }
ProxyP11Identity(ProxyP11Slot slot, P11IdentityId identityId) { super(slot, identityId, 0); this.asn1KeyId = new ProxyMessage.ObjectIdentifier(identityId.getKeyId()); }
public void addIdentity(P11Identity identity) { ParamUtil.requireNonNull("identity", identity); this.identities.put(identity.getId().getKeyId(), identity); }
public void addIdentity(P11Identity identity) { Args.notNull(identity, "identity"); this.identities.put(identity.getId().getKeyId(), identity); }
public P11Identity getIdentity(P11IdentityId identityId) throws P11TokenException { return getIdentity(identityId.getSlotId(), identityId.getKeyId()); }
public P11Identity getIdentity(P11IdentityId identityId) throws P11TokenException { return getIdentity(identityId.getSlotId(), identityId.getKeyId()); }
protected void addIdentity(P11Identity identity) throws P11DuplicateEntityException { if (!slotId.equals(identity.getId().getSlotId())) { throw new IllegalArgumentException("invalid identity"); } P11ObjectIdentifier keyId = identity.getId().getKeyId(); if (hasIdentity(keyId)) { throw new P11DuplicateEntityException(slotId, keyId); } identities.put(keyId, identity); updateCaCertsOfIdentity(identity); }
@Override protected void removeIdentity0(P11IdentityId identityId) throws P11TokenException { ASN1Object req = new ProxyMessage.SlotIdAndObjectId(asn1SlotId, new ProxyMessage.ObjectIdentifier(identityId.getKeyId())); module.send(P11ProxyConstants.ACTION_REMOVE_IDENTITY, req); }
protected void addIdentity(P11Identity identity) throws P11DuplicateEntityException { if (!slotId.equals(identity.getId().getSlotId())) { throw new IllegalArgumentException("invalid identity"); } P11ObjectIdentifier keyId = identity.getId().getKeyId(); if (hasIdentity(keyId)) { throw new P11DuplicateEntityException(slotId, keyId); } identities.put(keyId, identity); updateCaCertsOfIdentity(identity); }
/** * Removes the key (private key, public key, secret key, and certificates) associated with * the given identifier {@code objectId}. * * @param identityId * Identity identifier. Must not be {@code null}. * @throws P11TokenException * if PKCS#11 token exception occurs. */ public void removeIdentity(P11IdentityId identityId) throws P11TokenException { Args.notNull(identityId, "identityId"); assertWritable("removeIdentity"); P11ObjectIdentifier keyId = identityId.getKeyId(); if (identities.containsKey(keyId)) { if (identityId.getCertId() != null) { certificates.remove(identityId.getCertId()); } identities.get(keyId).setCertificates(null); identities.remove(keyId); updateCaCertsOfIdentities(); } removeIdentity0(identityId); }
/** * Removes the key (private key, public key, secret key, and certificates) associated with * the given identifier {@code objectId}. * * @param identityId * Identity identifier. Must not be {@code null}. * @throws P11TokenException * if PKCS#11 token exception occurs. */ public void removeIdentity(P11IdentityId identityId) throws P11TokenException { ParamUtil.requireNonNull("identityId", identityId); assertWritable("removeIdentity"); P11ObjectIdentifier keyId = identityId.getKeyId(); if (identities.containsKey(keyId)) { if (identityId.getCertId() != null) { certificates.remove(identityId.getCertId()); } identities.get(keyId).setCertificates(null); identities.remove(keyId); updateCaCertsOfIdentities(); } removeIdentity0(identityId); }
/** * Imports secret key object in the PKCS#11 token. The key itself will not be generated * within the PKCS#11 token. * * @param keyType * Key type * @param keyValue * Key value. Must not be {@code null}. * @param control * Control of the key generation process. Must not be {@code null}. * @return the identifier of the key within the PKCS#11 token. * @throws P11TokenException * if PKCS#11 token exception occurs. */ public P11ObjectIdentifier importSecretKey(long keyType, byte[] keyValue, P11NewKeyControl control) throws P11TokenException { ParamUtil.requireNonNull("control", control); assertWritable("createSecretKey"); assertNoIdentityAndCert(control.getId(), control.getLabel()); P11Identity identity = importSecretKey0(keyType, keyValue, control); addIdentity(identity); P11ObjectIdentifier objId = identity.getId().getKeyId(); LOG.info("created secret key {}", objId); return objId; }
/** * Imports secret key object in the PKCS#11 token. The key itself will not be generated * within the PKCS#11 token. * * @param keyType * Key type * @param keyValue * Key value. Must not be {@code null}. * @param control * Control of the key generation process. Must not be {@code null}. * @return the identifier of the key within the PKCS#11 token. * @throws P11TokenException * if PKCS#11 token exception occurs. */ public P11ObjectIdentifier importSecretKey(long keyType, byte[] keyValue, P11NewKeyControl control) throws P11TokenException { Args.notNull(control, "control"); assertWritable("createSecretKey"); assertNoIdentityAndCert(control.getId(), control.getLabel()); P11Identity identity = importSecretKey0(keyType, keyValue, control); addIdentity(identity); P11ObjectIdentifier objId = identity.getId().getKeyId(); LOG.info("created secret key {}", objId); return objId; }
@Override protected void removeIdentity0(P11IdentityId identityId) throws P11TokenException { P11ObjectIdentifier keyId = identityId.getKeyId(); boolean b1 = true; if (identityId.getCertId() != null) { removePkcs11Entry(certDir, identityId.getCertId()); } boolean b2 = removePkcs11Entry(privKeyDir, keyId); boolean b3 = true; if (identityId.getPublicKeyId() != null) { b3 = removePkcs11Entry(pubKeyDir, identityId.getPublicKeyId()); } boolean b4 = removePkcs11Entry(secKeyDir, keyId); if (! (b1 || b2 || b3 || b4)) { throw new P11UnknownEntityException(slotId, keyId); } }
signatureAlgId = AlgorithmUtil.getSigAlgId(null, conf); } else { PublicKey pubKey = slot.getIdentity(identityId.getKeyId()).getPublicKey(); signatureAlgId = AlgorithmUtil.getSigAlgId(pubKey, conf);
signatureAlgId = AlgorithmUtil.getSigAlgId(null, conf); } else { PublicKey pubKey = slot.getIdentity(identityId.getKeyId()).getPublicKey(); signatureAlgId = AlgorithmUtil.getSigAlgId(pubKey, conf);
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new SlotIdentifier(value.getSlotId())); vector.add(new ObjectIdentifier(value.getKeyId())); if (value.getPublicKeyId() != null) { String label = value.getPublicKeyId().getLabel(); vector.add(new DERTaggedObject(true, 1, new DERUTF8String(label))); } if (value.getCertId() != null) { String label = value.getCertId().getLabel(); vector.add(new DERTaggedObject(true, 2, new DERUTF8String(label))); } return new DERSequence(vector); }
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new Asn1P11SlotIdentifier(value.getSlotId())); vector.add(new Asn1P11ObjectIdentifier(value.getKeyId())); if (value.getPublicKeyId() != null) { String label = value.getPublicKeyId().getLabel(); vector.add(new DERTaggedObject(true, 1, new DERUTF8String(label))); } if (value.getCertId() != null) { String label = value.getCertId().getLabel(); vector.add(new DERTaggedObject(true, 2, new DERUTF8String(label))); } return new DERSequence(vector); }
try { Session session = bagEntry.value(); P11ObjectIdentifier keyId = identityId.getKeyId(); byte[] id = keyId.getId(); char[] label = keyId.getLabelChars();