|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.crypto.MACFactory
public abstract class MACFactory
Creates a Message Authentication Code MAC
using the specified parameters.
For more information on the cryptographic algorithms supported by this factory, see Crypto Algorithms.
MAC
,
SymmetricKeyFactory
Constructor Summary | ||
---|---|---|
|
protected |
MACFactory()
Creates a new MACFactory object. |
Method Summary | ||
---|---|---|
|
protected abstract MAC |
create(String algorithm,
String parameters,
SymmetricKey key)
Called to create the MAC . |
|
static Enumeration |
getAlgorithms()
Returns an Enumeration of String representing all of the
registered algorithms with this factory. |
|
protected abstract String[] |
getFactoryAlgorithms()
Called to determine what SymmetricKey 's are supported. |
|
static MAC |
getInstance(String algorithm,
SymmetricKey key)
Constructs and returns a new MAC . |
|
static MAC |
getInstance(SymmetricKey key)
Constructs and returns a new MAC . |
|
static void |
register(MACFactory factory)
Registers the given MACFactory object. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected MACFactory()
MACFactory
object.
This constructor is not used.
Method Detail |
---|
public static MAC getInstance(SymmetricKey key) throws NoSuchAlgorithmException, CryptoTokenException, CryptoUnsupportedOperationException
MAC
. A
MACFactory
object
is selected based on key.getAlgorithm()
, eg an HMAC key will return an HMAC object, and a DES key will return
a CBCMAC object.
key
- The key used to extract the key data from.
NoSuchAlgorithmException
- Thrown if the MAC cannot be constructed.
CryptoTokenException
- Thrown if an error occurs with the crypto
token or the crypto token is invalid.
CryptoUnsupportedOperationException
- Thrown if a call is made to
an unsupported operation.public static MAC getInstance(String algorithm, SymmetricKey key) throws NoSuchAlgorithmException, CryptoTokenException, CryptoUnsupportedOperationException
MAC
.
A MACFactory
object is selected based on the String alone.
The keydata will simply be extracted from the symmetric key.
algorithm
- A String containing the specified MAC algorithm. e.g. "HMAC/SHA1", "CBCMAC/DES"key
- The key used to extract key data from.
NoSuchAlgorithmException
- Thrown if the MAC cannot be constructed.
CryptoTokenException
- Thrown if an error occurs with the crypto
token or the crypto token is invalid.
CryptoUnsupportedOperationException
- Thrown if a call is made to
an unsupported operation.public static void register(MACFactory factory)
MACFactory
object.
If a previous call registered a MACFactory
with the same
algorithm name, then the this MACFactory
will not be added.
factory
- The MACFactory
object to be registered.public static Enumeration getAlgorithms()
String
representing all of the
registered algorithms with this factory.
protected abstract String[] getFactoryAlgorithms()
SymmetricKey
's are supported.
protected abstract MAC create(String algorithm, String parameters, SymmetricKey key) throws NoSuchAlgorithmException, ClassCastException, CryptoTokenException, CryptoUnsupportedOperationException, CryptoException
MAC
.
algorithm
- A String representing the name of the algorithm.parameters
- A String containing the paramters for the MAC.keyData
- The keydata used to create the MAC.offset
- The offset, or start position, of the data within the
array.length
- The length of the data, in bytes.
NoSuchAlgorithmException
- Thrown if an error occurs when creating
the MAC.
ClassCastException
- Thrown if the class is improperly cast.
CryptoTokenException
- Thrown if an error occurs with the crypto
token or the crypto token is invalid.
CryptoUnsupportedOperationException
- Thrown if a call is made to
an unsupported operation.
CryptoException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.