/** * Creates a {@link PemPrivateKey} from raw {@code byte[]}. * * ATTENTION: It's assumed that the given argument is a PEM/PKCS#8 encoded value. * No input validation is performed to validate it. */ public static PemPrivateKey valueOf(byte[] key) { return valueOf(Unpooled.wrappedBuffer(key)); }
/** * Creates a {@link PemPrivateKey} from raw {@code ByteBuf}. * * ATTENTION: It's assumed that the given argument is a PEM/PKCS#8 encoded value. * No input validation is performed to validate it. */ public static PemPrivateKey valueOf(ByteBuf key) { return new PemPrivateKey(key); }
@Override public PemPrivateKey retainedDuplicate() { return replace(content.retainedDuplicate()); }
/** * NOTE: This is a JDK8 interface/method. Due to backwards compatibility * reasons it's not possible to slap the {@code @Override} annotation onto * this method. * * @see Destroyable#isDestroyed() */ public boolean isDestroyed() { return refCnt() == 0; } }
/** * Return the pointer to a <a href="https://www.openssl.org/docs/crypto/BIO_get_mem_ptr.html">in-memory BIO</a> * or {@code 0} if the {@code key} is {@code null}. The BIO contains the content of the {@code key}. */ static long toBIO(ByteBufAllocator allocator, PrivateKey key) throws Exception { if (key == null) { return 0; } PemEncoded pem = PemPrivateKey.toPEM(allocator, true, key); try { return toBIO(allocator, pem.retain()); } finally { pem.release(); } }
@Override public PemPrivateKey duplicate() { return replace(content.duplicate()); }
/** * NOTE: This is a JDK8 interface/method. Due to backwards compatibility * reasons it's not possible to slap the {@code @Override} annotation onto * this method. * * @see Destroyable#isDestroyed() */ public boolean isDestroyed() { return refCnt() == 0; } }
/** * Return the pointer to a <a href="https://www.openssl.org/docs/crypto/BIO_get_mem_ptr.html">in-memory BIO</a> * or {@code 0} if the {@code key} is {@code null}. The BIO contains the content of the {@code key}. */ static long toBIO(ByteBufAllocator allocator, PrivateKey key) throws Exception { if (key == null) { return 0; } PemEncoded pem = PemPrivateKey.toPEM(allocator, true, key); try { return toBIO(allocator, pem.retain()); } finally { pem.release(); } }
@Override public PemPrivateKey copy() { return replace(content.copy()); }
@Override public ByteBuf content() { int count = refCnt(); if (count <= 0) { throw new IllegalReferenceCountException(count); } return content; }
@Override public PemPrivateKey replace(ByteBuf content) { return new PemPrivateKey(content); }
public static PrivateKey readPrivateKey(Path path) throws IOException { final byte[] bytes = Files.readAllBytes(path); return PemPrivateKey.valueOf(bytes); } }
/** * Return the pointer to a <a href="https://www.openssl.org/docs/crypto/BIO_get_mem_ptr.html">in-memory BIO</a> * or {@code 0} if the {@code key} is {@code null}. The BIO contains the content of the {@code key}. */ static long toBIO(ByteBufAllocator allocator, PrivateKey key) throws Exception { if (key == null) { return 0; } PemEncoded pem = PemPrivateKey.toPEM(allocator, true, key); try { return toBIO(allocator, pem.retain()); } finally { pem.release(); } }
@Override public PemPrivateKey copy() { return replace(content.copy()); }
@Override public ByteBuf content() { int count = refCnt(); if (count <= 0) { throw new IllegalReferenceCountException(count); } return content; }
/** * Creates a {@link PemPrivateKey} from raw {@code ByteBuf}. * * ATTENTION: It's assumed that the given argument is a PEM/PKCS#8 encoded value. * No input validation is performed to validate it. */ public static PemPrivateKey valueOf(ByteBuf key) { return new PemPrivateKey(key); }
/** * Creates a {@link PemPrivateKey} from raw {@code byte[]}. * * ATTENTION: It's assumed that the given argument is a PEM/PKCS#8 encoded value. * No input validation is performed to validate it. */ public static PemPrivateKey valueOf(byte[] key) { return valueOf(Unpooled.wrappedBuffer(key)); }