/** * Creates a thumbprint of an X509Certificate. * @param cert The certificate to convert. * @return A thumbprint of the certificate. */ public static Thumbprint toThumbprint(X509Certificate cert) { Thumbprint retVal = null; if (cert == null) throw new IllegalArgumentException(); try { retVal = new Thumbprint(cert); } catch (Exception e) { throw new NHINDException("", e); } catch (Throwable e) { throw new NHINDException(e); } return retVal; }
if (!e.getError().equals(AgentError.AllCertsInResolverInvalid)) throw e; throw new NHINDException(AgentError.Unexpected, ex);
if (exception.getError() != null) contexts.add(new DefaultAuditContext(AuditEvents.REJECTED_MESSAGE_REASON_CONTEXT, exception.getError().toString())); if (exception.getError() != null && exception.getError() instanceof AgentException && ((AgentException)exception.getError()).getError() == AgentError.NoTrustedRecipients)
if (e.getError().equals(AgentError.AllCertsInResolverInvalid)) break; else throw new NHINDException(AgentError.Unexpected, ex);
throw new NHINDException("Failed to download certificate from AIA extension.", e);
throw new NHINDException("", e);
protected static String getPartContentBodyAsString(BodyPart part) { try { Object content = part.getContent(); if (content instanceof String) return content.toString(); else if (content instanceof InputStream) { InputStream str = (InputStream)part.getContent(); byte[] bytes = new byte[str.available()]; str.read(bytes); return new String(bytes); } else return content.toString(); } catch (Exception e) { throw new NHINDException("Unable to handle get notification body as a string.", e); } } }
throw new NHINDException("Failed to download certificates from AIA extension (URL: " + url + ")", e);
throw new NHINDException("", e);
throw new NHINDException("Data cannot be converted to a valid X.509 Certificate", e);
/** * {@inheritDoc}} */ public synchronized PrivateKey getPrivateKey() { // this is on demand, so it needs to be synchronized if (wrappedKey != null) return wrappedKey; final WrappableKeyProtectionManager wrapManager = (WrappableKeyProtectionManager)mgr; // get the key algorithm from the public key... this will be needed // as a parameter to the unwrap method final String keyAlg = this.internalCert.getPublicKey().getAlgorithm(); try { wrappedKey = (PrivateKey)wrapManager.unwrapWithSecretKey((SecretKey)mgr.getPrivateKeyProtectionKey(), wrappedData, keyAlg, Cipher.PRIVATE_KEY); } catch (CryptoException e) { throw new NHINDException(AgentError.Unexpected, "Failed to access wrapped private key.", e); } return wrappedKey; } }
throw new NHINDException(AgentError.AllCertsInResolverInvalid);
/** * {@inheritDoc} */ @Override public Collection<X509Certificate> getAllCertificates() { final Collection<X509Certificate> retVal = new ArrayList<X509Certificate>(); try { for (Map.Entry<String, Entry> entry : storeMgr.getAllEntries().entrySet()) { if (entry.getValue() instanceof PrivateKeyEntry) { final PrivateKeyEntry privEntry = (PrivateKeyEntry)entry.getValue(); retVal.add(X509CertificateEx.fromX509Certificate( (X509Certificate)privEntry.getCertificate(), privEntry.getPrivateKey())); } } return retVal; } ///CLOVER:OFF catch (Exception e) { throw new NHINDException(AgentError.Unexpected, "Failed to get key entries from PKCS11 store.", e); } ///CLOVER:ON }
throw new NHINDException("WebService error getting certificates by subject: " + e.getMessage(), e); throw new NHINDException("WebService error getting certificates by domain: " + e.getMessage(), e);
/** * Parses the notification part fields of a MDN MimeMessage message. The message is expected to conform to the MDN specification * as described in RFC3798. * @return The notification part fields as a set of Internet headers. */ public static InternetHeaders getNotificationFieldsAsHeaders(MimeMessage message) { if (message == null) throw new IllegalArgumentException("Message can not be null"); MimeMultipart mm = null; try { ByteArrayDataSource dataSource = new ByteArrayDataSource(message.getRawInputStream(), message.getContentType()); mm = new MimeMultipart(dataSource); } catch (Exception e) { throw new NHINDException("Failed to parse notification fields.", e); } return getNotificationFieldsAsHeaders(mm); }
throw new NHINDException("Failed to parse notification fields.", e);
throw new NHINDException("", e); throw new NHINDException("Invalid certificate format requested"); } catch (NamingException e) { closeDirContext(ctx); throw new NHINDException("", e); } catch (CertificateException e) { closeDirContext(ctx); throw new NHINDException("", e);
@SuppressWarnings("deprecation") private static ASN1Object getObject( String oid, byte[] ext) throws AnnotatedException { ASN1InputStream aIn = null; try { aIn = new ASN1InputStream(ext); ASN1OctetString octs = (ASN1OctetString)aIn.readObject(); IOUtils.closeQuietly(aIn); aIn = new ASN1InputStream(octs.getOctets()); return aIn.readObject(); } catch (Exception e) { throw new NHINDException("exception processing extension " + oid, e); } finally { IOUtils.closeQuietly(aIn); } }
throw new NHINDException("WebService error getting all certificates: " + e.getMessage(), e);
throw new NHINDException(AgentError.Unexpected, "Resolved certifiate has wrapped data, but resolver has not been configured to unwrap it."); throw new NHINDException("Data cannot be converted to a valid X.509 Certificate", e);