@Override protected void removeCerts0(P11ObjectIdentifier objectId) throws P11TokenException { deletePkcs11Entry(certDir, objectId.getId()); }
public void setCertLabel(String certLabel) { if (certLabel != null) { this.certId = certLabel.equals(keyId.getLabel()) ? keyId : new P11ObjectIdentifier(keyId.getId(), certLabel); } else { this.certId = null; } }
@Override protected void updateCertificate0(P11ObjectIdentifier keyId, X509Certificate newCert) throws P11TokenException, CertificateException { removePkcs11Cert(keyId); savePkcs11Cert(keyId.getId(), keyId.getLabel(), newCert); }
/** * TODO. * @param slotId * Slot identifier. Must not be {@code null}. * @param keyId * Object identifier. Must not be {@code null}. * @param publicKeyLabel * Label of the public key * @param certLabel * Label of the certificate */ public P11IdentityId(P11SlotIdentifier slotId, P11ObjectIdentifier keyId, String publicKeyLabel, String certLabel) { this.slotId = ParamUtil.requireNonNull("slotId", slotId); this.keyId = ParamUtil.requireNonNull("keyId", keyId); if (publicKeyLabel != null) { this.publicKeyId = publicKeyLabel.equals(keyId.getLabel()) ? keyId : new P11ObjectIdentifier(keyId.getId(), publicKeyLabel); } else { this.publicKeyId = null; } if (certLabel != null) { this.certId = certLabel.equals(keyId.getLabel()) ? keyId : new P11ObjectIdentifier(keyId.getId(), certLabel); } else { this.certId = null; } }
/** * TODO. * @param slotId * Slot identifier. Must not be {@code null}. * @param keyId * Object identifier. Must not be {@code null}. * @param publicKeyLabel * Label of the public key * @param certLabel * Label of the certificate */ public P11IdentityId(P11SlotIdentifier slotId, P11ObjectIdentifier keyId, String publicKeyLabel, String certLabel) { this.slotId = Args.notNull(slotId, "slotId"); this.keyId = Args.notNull(keyId, "keyId"); if (publicKeyLabel != null) { this.publicKeyId = publicKeyLabel.equals(keyId.getLabel()) ? keyId : new P11ObjectIdentifier(keyId.getId(), publicKeyLabel); } else { this.publicKeyId = null; } if (certLabel != null) { this.certId = certLabel.equals(keyId.getLabel()) ? keyId : new P11ObjectIdentifier(keyId.getId(), certLabel); } else { this.certId = null; } }
private boolean removePkcs11Entry(File dir, P11ObjectIdentifier objectId) throws P11TokenException { byte[] id = objectId.getId(); String label = objectId.getLabel(); if (id != null) {
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vec = new ASN1EncodableVector(); vec.add(new DEROctetString(value.getId())); vec.add(new DERUTF8String(value.getLabel())); return new DERSequence(vec); }
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vec = new ASN1EncodableVector(); vec.add(new DEROctetString(value.getId())); vec.add(new DERUTF8String(value.getLabel())); return new DERSequence(vec); }
@Override protected void removeCerts0(P11ObjectIdentifier objectId) throws P11TokenException { if (vendor == Vendor.YUBIKEY) { throw new P11TokenException("Unsupported operation removeCerts() in yubikey token"); } ConcurrentBagEntry<Session> bagEntry = borrowSession(); try { Session session = bagEntry.value(); X509PublicKeyCertificate[] existingCerts = getCertificateObjects(session, objectId.getId(), objectId.getLabelChars()); if (existingCerts == null || existingCerts.length == 0) { LOG.warn("could not find certificates " + objectId); return; } for (X509PublicKeyCertificate cert : existingCerts) { session.destroyObject(cert); } } catch (TokenException ex) { throw new P11TokenException(ex.getMessage(), ex); } finally { sessions.requite(bagEntry); } }
@Override protected void updateCertificate0(P11ObjectIdentifier keyId, X509Certificate newCert) throws P11TokenException { try { removeCerts(keyId); } catch (P11UnknownEntityException ex) { // CHECKSTYLE: certificates do not exist, do nothing } try { Thread.sleep(1000); } catch (InterruptedException ex) { // CHECKSTYLE:SKIP } P11NewObjectControl control = new P11NewObjectControl(keyId.getId(), keyId.getLabel()); ConcurrentBagEntry<Session> bagEntry = borrowSession(); try { Session session = bagEntry.value(); X509PublicKeyCertificate newCertTemp = createPkcs11Template(session, new X509Cert(newCert), control); session.createObject(newCertTemp); } catch (TokenException ex) { throw new P11TokenException("could not createObject: " + ex.getMessage(), ex); } finally { sessions.requite(bagEntry); } }
Session session = bagEntry.value(); P11ObjectIdentifier keyId = identityId.getKeyId(); byte[] id = keyId.getId(); char[] label = keyId.getLabelChars(); SecretKey secretKey = getSecretKeyObject(session, id, label); if (pubKeyId != null) { PublicKey pubKey = getPublicKeyObject(session, pubKeyId.getId(), pubKeyId.getLabelChars()); if (pubKey != null) { try { if (certId != null) { X509PublicKeyCertificate[] certs = getCertificateObjects(session, certId.getId(), certId.getLabelChars()); if (certs != null && certs.length > 0) { for (int i = 0; i < certs.length; i++) {
getObjectIdsFromServer(P11ProxyConstants.ACTION_GET_IDENTITY_IDS); for (P11ObjectIdentifier keyId : keyIds) { byte[] id = keyId.getId();