/** * @param resourceKey A hint as to the origin of the text lines * @param beginMarker The line containing the begin marker * @param endMarker The line containing the end marker * @param passwordProvider The {@link FilePasswordProvider} to use * in case the data is encrypted - may be {@code null} if no encrypted * @param bytes The decoded bytes from the lines containing the data * @return The extracted {@link KeyPair}s - may be {@code null}/empty if none. * @throws IOException If failed to parse the data * @throws GeneralSecurityException If failed to generate the keys * @see #extractKeyPairs(String, String, String, FilePasswordProvider, InputStream) */ public Collection<KeyPair> extractKeyPairs( String resourceKey, String beginMarker, String endMarker, FilePasswordProvider passwordProvider, byte[] bytes) throws IOException, GeneralSecurityException { if (log.isTraceEnabled()) { BufferUtils.dumpHex(getSimplifiedLogger(), Level.FINER, beginMarker, ':', 16, bytes); } try (InputStream bais = new ByteArrayInputStream(bytes)) { return extractKeyPairs(resourceKey, beginMarker, endMarker, passwordProvider, bais); } }
/** * @param session The {@link SessionContext} for invoking this load command - may * be {@code null} if not invoked within a session context (e.g., offline tool or session unknown). * @param resourceKey A hint as to the origin of the text lines * @param beginMarker The line containing the begin marker * @param endMarker The line containing the end marker * @param passwordProvider The {@link FilePasswordProvider} to use * in case the data is encrypted - may be {@code null} if no encrypted * @param bytes The decoded bytes from the lines containing the data * @return The extracted {@link KeyPair}s - may be {@code null}/empty if none. * @throws IOException If failed to parse the data * @throws GeneralSecurityException If failed to generate the keys */ public Collection<KeyPair> extractKeyPairs( SessionContext session, NamedResource resourceKey, String beginMarker, String endMarker, FilePasswordProvider passwordProvider, byte[] bytes) throws IOException, GeneralSecurityException { if (log.isTraceEnabled()) { BufferUtils.dumpHex(getSimplifiedLogger(), Level.FINER, beginMarker, ':', 16, bytes); } try (InputStream bais = new ByteArrayInputStream(bytes)) { return extractKeyPairs(session, resourceKey, beginMarker, endMarker, passwordProvider, bais); } }