@Override protected void removeCerts0(final P11ObjectIdentifier objectId) throws P11TokenException { X509PublicKeyCertificate[] existingCerts = getCertificateObjects(objectId.id(), objectId.labelChars()); if (existingCerts == null || existingCerts.length == 0) { LOG.warn("could not find certificates " + objectId); return; } Session session = borrowWritableSession(); try { for (X509PublicKeyCertificate cert : existingCerts) { session.destroyObject(cert); } } catch (TokenException ex) { throw new P11TokenException(ex.getMessage(), ex); } finally { returnWritableSession(session); } }
@Override protected void updateCertificate0(final P11ObjectIdentifier objectId, final X509Certificate newCert) throws P11TokenException { removeCerts(objectId); try { Thread.sleep(1000); } catch (InterruptedException ex) { // CHECKSTYLE:SKIP } X509PublicKeyCertificate newCertTemp = createPkcs11Template(new X509Cert(newCert), objectId.id(), objectId.labelChars()); Session session = borrowWritableSession(); try { session.createObject(newCertTemp); } catch (TokenException ex) { throw new P11TokenException("could not createObject: " + ex.getMessage(), ex); } finally { returnWritableSession(session); } }
@Override protected void addCert0(final P11ObjectIdentifier objectId, final X509Certificate cert) throws P11TokenException { X509PublicKeyCertificate newCaCertTemp = createPkcs11Template( new X509Cert(cert), objectId.id(), objectId.labelChars()); Session session = borrowWritableSession(); try { session.createObject(newCaCertTemp); } catch (TokenException ex) { throw new P11TokenException(ex.getMessage(), ex); } finally { returnWritableSession(session); } }
try { byte[] id = objectId.id(); char[] label = objectId.labelChars(); SecretKey secretKey = getSecretKeyObject(id, label); if (secretKey != null) {