Class OpenSSLKey
public class OpenSSLKey extends Object
-
Constructor Summary
Constructors Constructor Description OpenSSLKey(long ctx)OpenSSLKey(long ctx, OpenSSLEngine engine, String alias) -
Method Summary
Modifier and Type Method Description booleanequals(Object o)Compares this instance with the specified object and indicates if they are equal.protected voidfinalize()Invoked when the garbage collector has detected that this instance is no longer reachable.static OpenSSLKeyfromPrivateKey(PrivateKey key)StringgetAlias()longgetPkeyContext()Returns the raw pointer to the EVP_PKEY context for use in JNI calls.PrivateKeygetPrivateKey()PublicKeygetPublicKey()SecretKeygetSecretKey(String algorithm)inthashCode()Returns an integer hash code for this object.
-
Constructor Details
-
OpenSSLKey
public OpenSSLKey(long ctx) -
OpenSSLKey
-
-
Method Details
-
getPkeyContext
public long getPkeyContext()Returns the raw pointer to the EVP_PKEY context for use in JNI calls. The life cycle of this native pointer is managed by theOpenSSLKeyinstance and must not be destroyed or freed by users of this API. -
getAlias
-
fromPrivateKey
- Throws:
InvalidKeyException
-
getPublicKey
- Throws:
NoSuchAlgorithmException
-
getPrivateKey
- Throws:
NoSuchAlgorithmException
-
getSecretKey
- Throws:
NoSuchAlgorithmException
-
finalize
Description copied from class:ObjectInvoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.Note that objects that override
finalizeare significantly more expensive than objects that don't. Finalizers may be run a long time after the object is no longer reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup. Note also that finalizers are run on a single VM-wide finalizer thread, so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary for a class that has a native peer and needs to call a native method to destroy that peer. Even then, it's better to provide an explicitclosemethod (and implementCloseable), and insist that callers manually dispose of instances. This works well for something like files, but less well for something like aBigIntegerwhere typical calling code would have to deal with lots of temporaries. Unfortunately, code that creates lots of temporaries is the worst kind of code from the point of view of the single finalizer thread.If you must use finalizers, consider at least providing your own
ReferenceQueueand having your own thread process that queue.Unlike constructors, finalizers are not automatically chained. You are responsible for calling
super.finalize()yourself.Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.
-
equals
Description copied from class:ObjectCompares this instance with the specified object and indicates if they are equal. In order to be equal,omust represent the same object as this instance using a class-specific comparison. The general contract is that this comparison should be reflexive, symmetric, and transitive. Also, no object reference other than null is equal to null.The default implementation returns
trueonly ifthis == o. See Writing a correctequalsmethod if you intend implementing your ownequalsmethod.The general contract for the
equalsandObject.hashCode()methods is that ifequalsreturnstruefor any two objects, thenhashCode()must return the same value for these objects. This means that subclasses ofObjectusually override either both methods or neither of them.- Overrides:
equalsin classObject- Parameters:
o- the object to compare this instance with.- Returns:
trueif the specified object is equal to thisObject;falseotherwise.- See Also:
Object.hashCode()
-
hashCode
public int hashCode()Description copied from class:ObjectReturns an integer hash code for this object. By contract, any two objects for whichObject.equals(java.lang.Object)returnstruemust return the same hash code value. This means that subclasses ofObjectusually override both methods or neither method.Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCodemethod if you intend implementing your ownhashCodemethod.- Overrides:
hashCodein classObject- Returns:
- this object's hash code.
- See Also:
Object.equals(java.lang.Object)
-