Package org.wildfly.security.util
Class AbstractAlgorithmParametersSpiImpl<P extends AlgorithmParameterSpec>
- java.lang.Object
-
- java.security.AlgorithmParametersSpi
-
- org.wildfly.security.util.AbstractAlgorithmParametersSpiImpl<P>
-
- Type Parameters:
P
- the parameter type represented by the subclass
- Direct Known Subclasses:
DigestPasswordAlgorithmParametersSpiImpl
,IteratedPasswordAlgorithmParametersSpiImpl
,IteratedSaltedPasswordAlgorithmParametersSpiImpl
,MaskedPasswordAlgorithmParametersSpiImpl
,OneTimePasswordAlgorithmParametersSpiImpl
,RSAParameterSpiImpl
,SaltedPasswordAlgorithmParametersSpiImpl
public abstract class AbstractAlgorithmParametersSpiImpl<P extends AlgorithmParameterSpec> extends AlgorithmParametersSpi
A base class for classes which implementAlgorithmParametersSpi
that encode parameters using ASN.1.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]
encoded
private P
parameterSpec
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractAlgorithmParametersSpiImpl()
Construct a new instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private void
checkInit()
protected abstract P
engineDecode(ASN1Decoder decoder)
Decode a parameter instance.protected abstract void
engineEncode(ASN1Encoder encoder, P parameters)
Encode a parameter instance.protected byte[]
engineGetEncoded()
Implementation of theengineGetEncoded
method.protected byte[]
engineGetEncoded(String format)
Implementation of theengineGetEncoded
method.protected <T extends AlgorithmParameterSpec>
TengineGetParameterSpec(Class<T> type)
Implementation of theengineGetParameterSpec
method.protected void
engineInit(byte[] params)
Implementation of theengineInit
method.protected void
engineInit(byte[] params, String format)
Implementation of theengineInit
method.protected void
engineInit(AlgorithmParameterSpec paramSpec)
Implementation of theengineInit
method.protected String
engineToString()
Implementation of theengineToString
method.protected abstract Class<P>
getParameterType()
Get the type of parameters for this class.
-
-
-
Field Detail
-
parameterSpec
private P extends AlgorithmParameterSpec parameterSpec
-
encoded
private byte[] encoded
-
-
Method Detail
-
getParameterType
protected abstract Class<P> getParameterType()
Get the type of parameters for this class.- Returns:
- the type of parameters for this class (must not be
null
)
-
engineInit
protected final void engineInit(AlgorithmParameterSpec paramSpec) throws InvalidParameterSpecException
Implementation of theengineInit
method.- Specified by:
engineInit
in classAlgorithmParametersSpi
- Parameters:
paramSpec
- the parameter specification- Throws:
InvalidParameterSpecException
- if an argument is invalid or encoding failed
-
engineInit
protected final void engineInit(byte[] params) throws IOException
Implementation of theengineInit
method.- Specified by:
engineInit
in classAlgorithmParametersSpi
- Parameters:
params
- the encoded parameter specification- Throws:
IOException
- if decoding failed
-
engineInit
protected final void engineInit(byte[] params, String format) throws IOException
Implementation of theengineInit
method.- Specified by:
engineInit
in classAlgorithmParametersSpi
- Parameters:
params
- the encoded parameter specificationformat
- the format (must beASN.1
)- Throws:
IOException
- if decoding failed or the format is not equal toASN.1
-
engineEncode
protected abstract void engineEncode(ASN1Encoder encoder, P parameters) throws ASN1Exception, InvalidParameterSpecException
Encode a parameter instance.- Parameters:
encoder
- the encoder to use (notnull
)parameters
- the parameter instance (notnull
)- Throws:
ASN1Exception
- if there is an encoding problem (usually thrown directly by theASN1Encoder
)InvalidParameterSpecException
- if some other encoding error occurred
-
engineDecode
protected abstract P engineDecode(ASN1Decoder decoder) throws ASN1Exception, IOException
Decode a parameter instance. Subclasses should ensure that all elements are consumed (including sequence terminators and so forth).- Parameters:
decoder
- the decoder to use (notnull
)- Returns:
- the parameter instance (must not be
null
) - Throws:
ASN1Exception
- if there is a decoding problem (usually thrown directly by theASN1Decoder
)IOException
- if some other decoding error occurred
-
engineGetParameterSpec
protected final <T extends AlgorithmParameterSpec> T engineGetParameterSpec(Class<T> type) throws InvalidParameterSpecException
Implementation of theengineGetParameterSpec
method.- Specified by:
engineGetParameterSpec
in classAlgorithmParametersSpi
- Type Parameters:
T
- the parameter specification type- Parameters:
type
- the parameter specification type class (must not benull
)- Returns:
- the parameter specification (must not be
null
) - Throws:
InvalidParameterSpecException
- if the type is not supported
-
engineGetEncoded
protected final byte[] engineGetEncoded()
Implementation of theengineGetEncoded
method.- Specified by:
engineGetEncoded
in classAlgorithmParametersSpi
- Returns:
- the encoded representation (not
null
)
-
engineGetEncoded
protected final byte[] engineGetEncoded(String format) throws IOException
Implementation of theengineGetEncoded
method.- Specified by:
engineGetEncoded
in classAlgorithmParametersSpi
- Parameters:
format
- the format string (must not benull
)- Returns:
- the encoded representation (not
null
) - Throws:
IOException
- if the given format is notASN.1
-
checkInit
private void checkInit()
-
engineToString
protected String engineToString()
Implementation of theengineToString
method.- Specified by:
engineToString
in classAlgorithmParametersSpi
- Returns:
- the string representation
-
-