private static void closeWriter(Writer writer) { try { writer.close(); } catch (Exception ex) { LogUtil.warn(LOG, ex, "could not close writer"); } }
private static void closeWriter(Writer writer) { try { writer.close(); } catch (Exception ex) { LogUtil.warn(LOG, ex, "could not close writer"); } }
public static void releaseResources(DataSourceWrapper datasource, Statement ps, ResultSet rs) { if (ps != null) { try { ps.close(); } catch (SQLException ex) { DataAccessException dex = datasource.translate(null, ex); LogUtil.warn(LOG, dex, "could not close Statement"); } } if (rs != null) { try { rs.close(); } catch (SQLException ex) { DataAccessException dex = datasource.translate(null, ex); LogUtil.warn(LOG, dex, "could not close ResultSet"); } } }
@Override public void notifyCaChange() throws CaMgmtException { try { SystemEvent systemEvent = new SystemEvent(EVENT_CACHAGNE, lockInstanceId, System.currentTimeMillis() / 1000L); queryExecutor.changeSystemEvent(systemEvent); LOG.info("notified the change of CA system"); } catch (CaMgmtException ex) { LogUtil.warn(LOG, ex, "could not notify slave CAs to restart"); throw ex; } } // method notifyCaChange
@Override public byte[] getSignature() { try { byte[] dataToSign = outputStream.toByteArray(); outputStream.reset(); return cryptService.getIdentity(identityId).sign(mechanism, null, dataToSign); } catch (P11TokenException ex) { LogUtil.warn(LOG, ex); throw new RuntimeCryptoException("P11TokenException: " + ex.getMessage()); } catch (Throwable th) { LogUtil.warn(LOG, th); throw new RuntimeCryptoException(th.getClass().getName() + ": " + th.getMessage()); } }
@Override public byte[] getSignature() { try { byte[] dataToSign = outputStream.toByteArray(); outputStream.reset(); return cryptService.getIdentity(identityId).sign(mechanism, null, dataToSign); } catch (P11TokenException ex) { LogUtil.warn(LOG, ex); throw new RuntimeCryptoException("P11TokenException: " + ex.getMessage()); } catch (Throwable th) { LogUtil.warn(LOG, th); throw new RuntimeCryptoException(th.getClass().getName() + ": " + th.getMessage()); } }
@Override public byte[] getSignature() { try { byte[] plainSignature = getPlainSignature(); return plain ? plainSignature : SignerUtil.dsaSigPlainToX962(plainSignature); } catch (XiSecurityException ex) { LogUtil.warn(LOG, ex); throw new RuntimeCryptoException("XiSecurityException: " + ex.getMessage()); } catch (Throwable th) { LogUtil.warn(LOG, th); throw new RuntimeCryptoException(th.getClass().getName() + ": " + th.getMessage()); } }
@Override public byte[] getSignature() { try { byte[] plainSignature = getPlainSignature(); return SignerUtil.dsaSigPlainToX962(plainSignature); } catch (XiSecurityException ex) { LogUtil.warn(LOG, ex); throw new RuntimeCryptoException("XiSecurityException: " + ex.getMessage()); } catch (Throwable th) { LogUtil.warn(LOG, th); throw new RuntimeCryptoException(th.getClass().getName() + ": " + th.getMessage()); } }
@Override public byte[] getSignature() { try { byte[] plainSignature = getPlainSignature(); return plain ? plainSignature : SignerUtil.dsaSigPlainToX962(plainSignature); } catch (XiSecurityException ex) { LogUtil.warn(LOG, ex); throw new RuntimeCryptoException("XiSecurityException: " + ex.getMessage()); } catch (Throwable th) { LogUtil.warn(LOG, th); throw new RuntimeCryptoException(th.getClass().getName() + ": " + th.getMessage()); } }
@Override public byte[] getSignature() { try { byte[] plainSignature = getPlainSignature(); return plain ? plainSignature : SignerUtil.dsaSigPlainToX962(plainSignature); } catch (XiSecurityException ex) { LogUtil.warn(LOG, ex); throw new RuntimeCryptoException("XiSecurityException: " + ex.getMessage()); } catch (Throwable th) { LogUtil.warn(LOG, th); throw new RuntimeCryptoException(th.getClass().getName() + ": " + th.getMessage()); } }
@Override public byte[] getSignature() { try { byte[] plainSignature = getPlainSignature(); return plain ? plainSignature : SignerUtil.dsaSigPlainToX962(plainSignature); } catch (XiSecurityException ex) { LogUtil.warn(LOG, ex); throw new RuntimeCryptoException("XiSecurityException: " + ex.getMessage()); } catch (Throwable th) { LogUtil.warn(LOG, th); throw new RuntimeCryptoException(th.getClass().getName() + ": " + th.getMessage()); } }
@Override public byte[] getSignature() { try { byte[] plainSignature = getPlainSignature(); return SignerUtil.dsaSigPlainToX962(plainSignature); } catch (XiSecurityException ex) { LogUtil.warn(LOG, ex); throw new RuntimeCryptoException("XiSecurityException: " + ex.getMessage()); } catch (Throwable th) { LogUtil.warn(LOG, th); throw new RuntimeCryptoException(th.getClass().getName() + ": " + th.getMessage()); } }
void shutdownPublisher(IdentifiedCertPublisher publisher) { if (publisher == null) { return; } try { publisher.close(); } catch (Exception ex) { LogUtil.warn(LOG, ex, "could not shutdown CertPublisher " + publisher.getIdent()); } } // method shutdownPublisher
void shutdownCertprofile(IdentifiedCertprofile profile) { if (profile == null) { return; } try { profile.close(); } catch (Exception ex) { LogUtil.warn(LOG, ex, "could not shutdown Certprofile " + profile.getIdent()); } } // method shutdownCertprofile
public synchronized void refresh() throws P11TokenException { LOG.info("refreshing PKCS#11 module {}", module.getName()); List<P11SlotIdentifier> slotIds = module.getSlotIds(); for (P11SlotIdentifier slotId : slotIds) { P11Slot slot; try { slot = module.getSlot(slotId); } catch (P11TokenException ex) { LogUtil.warn(LOG, ex, "P11TokenException while initializing slot " + slotId); continue; } catch (Throwable th) { LOG.error("unexpected error while initializing slot " + slotId, th); continue; } slot.refresh(); } LOG.info("refreshed PKCS#11 module {}", module.getName()); } // method refresh
public synchronized void refresh() throws P11TokenException { LOG.info("refreshing PKCS#11 module {}", module.getName()); List<P11SlotIdentifier> slotIds = module.getSlotIds(); for (P11SlotIdentifier slotId : slotIds) { P11Slot slot; try { slot = module.getSlot(slotId); } catch (P11TokenException ex) { LogUtil.warn(LOG, ex, "P11TokenException while initializing slot " + slotId); continue; } catch (Throwable th) { LOG.error("unexpected error while initializing slot " + slotId, th); continue; } slot.refresh(); } LOG.info("refreshed PKCS#11 module {}", module.getName()); } // method refresh
@Override public byte[] getSignature() { if (outputStream instanceof PSSSignerOutputStream) { try { return ((PSSSignerOutputStream) outputStream).generateSignature(); } catch (CryptoException ex) { LogUtil.warn(LOG, ex); throw new RuntimeCryptoException("CryptoException: " + ex.getMessage()); } } byte[] dataToSign; if (outputStream instanceof ByteArrayOutputStream) { dataToSign = ((ByteArrayOutputStream) outputStream).toByteArray(); } else { dataToSign = ((DigestOutputStream) outputStream).digest(); } try { return cryptService.getIdentity(identityId).sign(mechanism, parameters, dataToSign); } catch (P11TokenException ex) { LogUtil.warn(LOG, ex, "could not sign"); throw new RuntimeCryptoException("SignerException: " + ex.getMessage()); } }
@Override public byte[] getSignature() { if (outputStream instanceof PSSSignerOutputStream) { try { return ((PSSSignerOutputStream) outputStream).generateSignature(); } catch (CryptoException ex) { LogUtil.warn(LOG, ex); throw new RuntimeCryptoException("CryptoException: " + ex.getMessage()); } } byte[] dataToSign; if (outputStream instanceof ByteArrayOutputStream) { dataToSign = ((ByteArrayOutputStream) outputStream).toByteArray(); } else { dataToSign = ((DigestOutputStream) outputStream).digest(); } try { return cryptService.getIdentity(identityId).sign(mechanism, parameters, dataToSign); } catch (P11TokenException ex) { LogUtil.warn(LOG, ex, "could not sign"); throw new RuntimeCryptoException("SignerException: " + ex.getMessage()); } }
public ConcurrentContentSigner createSigner(AlgorithmIdentifier signatureAlgId, int parallelism) throws XiSecurityException, P11TokenException { ParamUtil.requireMin("parallelism", parallelism, 1); List<XiContentSigner> signers = new ArrayList<>(parallelism); for (int i = 0; i < parallelism; i++) { XiContentSigner signer = new P11MacContentSigner(cryptService, identityId, signatureAlgId); signers.add(signer); } // end for final boolean mac = true; DfltConcurrentContentSigner concurrentSigner; try { concurrentSigner = new DfltConcurrentContentSigner(mac, signers, null); } catch (NoSuchAlgorithmException ex) { throw new XiSecurityException(ex.getMessage(), ex); } try { byte[] sha1HashOfKey = cryptService.getIdentity(identityId).digestSecretKey( PKCS11Constants.CKM_SHA_1); concurrentSigner.setSha1DigestOfMacKey(sha1HashOfKey); } catch (P11TokenException | XiSecurityException ex) { LogUtil.warn(LOG, ex, "could not compute the digest of secret key " + identityId); } return concurrentSigner; } // method createSigner
public boolean isOnService() { X509Ca ca; try { ca = caManager.getX509Ca(caIdent); } catch (CaMgmtException ex) { LogUtil.warn(LOG, ex); return false; } if (ca == null) { return false; } if (!ca.getCaInfo().supportsScep()) { return false; } return ca.getCaInfo().getStatus() == CaStatus.ACTIVE; }