- All Superinterfaces:
WebCertificateReference,WebKeyReference
- All Known Implementing Classes:
Jwk
Unifies algorithm support and maps a cryptographic key from JCE to JSON Web
Key.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumEnumerates supported signature and encryption algorithms.static interfaceWebKey.Builder<B extends WebKey.Builder<B>>Builder interface for creatingWebKeyinstances.static enumEnumerates key operations.static enumEnumerates key type.static enumEnumerates public key use. -
Method Summary
Modifier and TypeMethodDescriptionstatic AlgorithmParameterSpecalgorithmParams(String name) Gets theECParameterSpecfor a standard parameter name.static AlgorithmParameterSpecalgorithmParams(Key key) Gets theAlgorithmParameterSpecfrom a key.static StringSerializesWebKeys as a JSON Web Key Set.static WebKey.Builder<?> builder(WebKey.Algorithm algorithm) Creates an ephemeral key for use as JWE recipient or JWS issuer.static WebKey.Builder<?> builder(WebKey.Type type) Creates a newWebKey.Builder.static WebKey.Builder<?> Creates a new builder.static WebKeyephemeral(WebEncryption.Encryption encryption) Creates an ephemeral content encryption key, for use withWebKey.Algorithm.DIRECT.static WebKeyephemeral(WebKey.Algorithm algorithm) Creates an ephemeral key for use as JWE recipient or JWS issuer.byte[]getKey()Gets the raw key data for use whenWebKey.Type.RAW.getOps()Gets the key operations.Gets the JCE private key implementation.Gets the JCE public key implementation.getType()Gets the key type.getUse()Gets the public key use.static WebKeyParses a JSON Web Key (JWK).Parses a JSON Web Key Set (JWKS).static WebKeyReads at least one PEM-encoded X509 certificate, and optionally a private key, and returns a JWK partial-key representation.readJwks(InputStream jwks) Reads a JSON Web Key Set (JWKS).Reads a JSON Web Key Set (JWKS).static PublicKeyVerifies encoded key data is correct for the key type, use, algorithm, and X.509 certificate chain.Returns a copy of this key for whichgetPrivateKey()andgetKey()always return null, and for which the source data backing these methods is not populated.static voidwriteJwks(Iterable<? extends WebKey> webKeys, OutputStream out) WritesWebKeyas a JSON Web Key.Methods inherited from interface edu.iu.crypt.WebCertificateReference
getCertificateChain, getCertificateSha256Thumbprint, getCertificateThumbprint, getCertificateUriMethods inherited from interface edu.iu.crypt.WebKeyReference
getAlgorithm, getKeyId
-
Method Details
-
algorithmParams
Gets theECParameterSpecfor a standard parameter name.- Parameters:
name- standard parameter name- Returns:
- Elliptic Curve parameters
-
algorithmParams
Gets theAlgorithmParameterSpecfrom a key.- Parameters:
key- key- Returns:
AlgorithmParameterSpec
-
verify
Verifies encoded key data is correct for the key type, use, algorithm, and X.509 certificate chain.- Parameters:
webKey-WebKey- Returns:
PublicKeyresolved from the web key, or null if no public key was resolved; private and raw key values will be verified as valid for the key type and/or public key, and may continue to be accessed from the original web key as needed.- Throws:
IllegalArgumentException- if the key is invalid
-
builder
Creates a new builder.- Parameters:
key- JCE key- Returns:
WebKey.Builder
-
builder
Creates a newWebKey.Builder.- Parameters:
type- key type- Returns:
WebKey.Builder
-
builder
Creates an ephemeral key for use as JWE recipient or JWS issuer.Ephemeral keys are generated using JDK 11 compliant standard algorithms with
registered JCE providers- Parameters:
algorithm- key algorithm- Returns:
- JWE recipient or JWS issuer key
-
ephemeral
Creates an ephemeral content encryption key, for use withWebKey.Algorithm.DIRECT.Ephemeral keys are generated using JDK 11 compliant standard algorithms with
registered JCE providers- Parameters:
encryption- encryption algorithm- Returns:
- content encryption key
-
ephemeral
Creates an ephemeral key for use as JWE recipient or JWS issuer.Ephemeral keys are generated using JDK 11 compliant standard algorithms with
registered JCE providers- Parameters:
algorithm- key algorithm- Returns:
- JWE recipient or JWS issuer key
-
parse
Parses a JSON Web Key (JWK).- Parameters:
jwk- JSON Web Key- Returns:
WebKey
-
parseJwks
Parses a JSON Web Key Set (JWKS).- Parameters:
jwks- serialized JWKS- Returns:
- parsed key set
-
pem
Reads at least one PEM-encoded X509 certificate, and optionally a private key, and returns a JWK partial-key representation.- Parameters:
pem- PEM-encoded certificate(s) and optional private key- Returns:
WebKey
-
readJwks
Reads a JSON Web Key Set (JWKS).- Parameters:
jwks- serialized JWKS- Returns:
- parsed key set
-
readJwks
Reads a JSON Web Key Set (JWKS).- Parameters:
jwks- serialized JWKS- Returns:
- parsed key set
-
asJwks
SerializesWebKeys as a JSON Web Key Set.- Parameters:
webKeys-WebKeys- Returns:
- serialized JWKS
-
writeJwks
WritesWebKeyas a JSON Web Key.- Parameters:
webKeys-WebKeysout-OutputStream
-
wellKnown
WebKey wellKnown()Returns a copy of this key for whichgetPrivateKey()andgetKey()always return null, and for which the source data backing these methods is not populated.If these methods would already return null, this key is returned as-is.
- Returns:
- this key, or a copy that omits secret and private key data
-
getType
WebKey.Type getType()Gets the key type.- Returns:
- key type
-
getUse
WebKey.Use getUse()Gets the public key use.- Returns:
- public key use.
-
getOps
Set<WebKey.Operation> getOps()Gets the key operations.- Returns:
- key operations
-
getKey
byte[] getKey()Gets the raw key data for use whenWebKey.Type.RAW.- Returns:
- raw key data
-
getPrivateKey
PrivateKey getPrivateKey()Gets the JCE private key implementation.- Returns:
PrivateKey
-
getPublicKey
PublicKey getPublicKey()Gets the JCE public key implementation.- Returns:
PublicKey
-