|
TrueLicense Core 1.33 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.schlichtherle.license.LicenseNotary
public class LicenseNotary
This notary knows how to sign and verify a GenericCertificate.
This class is not thread safe.
| Field Summary | |
|---|---|
private static String |
ALIAS
=> "alias" |
private static int |
BUFSIZE
The buffer size for I/O. |
private static String |
EXC_NO_CERTIFICATE_ENTRY
=> "exc.noCertificateEntry" |
private static String |
EXC_NO_KEY_ENTRY
=> "exc.noKeyEntry" |
private static String |
EXC_NO_KEY_PWD
=> "exc.noKeyPwd" |
private static String |
EXC_PRIVATE_KEY_OR_PWD_IS_NOT_ALLOWED
=> "exc.privateKeyOrPwdIsNotAllowed" |
private static String |
JKS
=> "JKS" |
private KeyStore |
keyStore
|
private KeyStoreParam |
param
|
(package private) static String |
PARAM
=> "param" |
private PrivateKey |
privateKey
|
private PublicKey |
publicKey
|
private static String |
SHA1_WITH_DSA
=> "SHA1withDSA" |
| Constructor Summary | |
|---|---|
protected |
LicenseNotary()
Creates a new License Notary. |
|
LicenseNotary(KeyStoreParam param)
Creates a new License Notary. |
| Method Summary | |
|---|---|
protected KeyStore |
getKeyStore()
Returns a loaded/initialized keyStore. |
KeyStoreParam |
getKeyStoreParam()
Returns the keyStore configuration parameters. |
protected PrivateKey |
getPrivateKey()
Returns the private key from the keyStore. |
protected PublicKey |
getPublicKey()
Returns the public key from the keyStore |
protected Signature |
getSignatureEngine()
Returns a valid signature engine to be used for signing and verifying a GenericCertificate - null is never returned. |
void |
setKeyStoreParam(KeyStoreParam param)
Sets the keyStore configuration parameters. |
private void |
setKeyStoreParam0(KeyStoreParam param)
|
(package private) void |
sign(GenericCertificate certificate,
Object content)
Encodes and signs the given content in the given
certificate and locks it. |
GenericCertificate |
sign(Object content)
Encodes and signs the given content and returns a locked
generic certificate holding the encoded content and its digital
signature. |
void |
verify(GenericCertificate certificate)
Verifies the digital signature of the encoded content in the given certificate and locks it. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final String ALIAS
private static final int BUFSIZE
private static final String EXC_NO_CERTIFICATE_ENTRY
private static final String EXC_NO_KEY_ENTRY
private static final String EXC_NO_KEY_PWD
private static final String EXC_PRIVATE_KEY_OR_PWD_IS_NOT_ALLOWED
private static final String JKS
private KeyStore keyStore
private KeyStoreParam param
static final String PARAM
private PrivateKey privateKey
private PublicKey publicKey
private static final String SHA1_WITH_DSA
| Constructor Detail |
|---|
protected LicenseNotary()
Warning: The notary created by this constructor is not
valid and cannot be used unless setKeyStoreParam(KeyStoreParam)
is called!
public LicenseNotary(KeyStoreParam param)
param - the keyStore configuration parameters
- may not be null.
NullPointerException - if the given parameter object does not
obey the contract of its interface due to a null
pointer.
IllegalPasswordException - if any password in the parameter object
does not comply to the current policy.| Method Detail |
|---|
protected KeyStore getKeyStore()
throws IOException,
CertificateException,
NoSuchAlgorithmException
IOException - if there is an I/O or format problem with the
keyStore data.
CertificateException - if any of the certificates in the
keyStore could not be loaded.
NoSuchAlgorithmException - if the algorithm used to check
the integrity of the keyStore cannot be found.public KeyStoreParam getKeyStoreParam()
protected PrivateKey getPrivateKey()
throws LicenseNotaryException,
IOException,
CertificateException,
NoSuchAlgorithmException,
UnrecoverableKeyException
LicenseNotaryException - if the parameters used to access the
corresponding key store are insufficient or incorrect.
Note that you should always use
Throwable.getLocalizedMessage() to get a (possibly
localized) meaningful detail message.
IOException - if there is an I/O or format problem with the
keyStore data.
CertificateException - if any of the certificates in the
keyStore could not be loaded.
NoSuchAlgorithmException - if the algorithm used to check
the integrity of the keyStore cannot be found.
UnrecoverableKeyException - if the key cannot get recovered
(e.g. the given password is wrong).
protected PublicKey getPublicKey()
throws LicenseNotaryException,
IOException,
CertificateException,
NoSuchAlgorithmException
LicenseNotaryException - if the parameters used to access the
corresponding key store are insufficient or incorrect.
Note that you should always use
Throwable.getLocalizedMessage() to get a (possibly
localized) meaningful detail message.
IOException - if there is an I/O or format problem with the
keyStore data.
CertificateException - if any of the certificates in the
keyStore could not be loaded.
NoSuchAlgorithmException - if the algorithm used to check
the integrity of the keyStore cannot be found.protected Signature getSignatureEngine()
GenericCertificate - null is never returned.
public void setKeyStoreParam(KeyStoreParam param)
param - the keyStore configuration parameters
- may not be null.
NullPointerException - if the given parameter object does not
obey the contract of its interface due to a null
pointer.
IllegalPasswordException - if any password in the parameter object
does not comply to the current policy.private void setKeyStoreParam0(KeyStoreParam param)
void sign(GenericCertificate certificate,
Object content)
throws Exception
content in the given
certificate and locks it.
Please note the following:
PropertyVetoException if the
certificate is already locked, i.e. if it has been signed or
verified before.sign(GenericCertificate, Object) or
verify(GenericCertificate) is redundant
and will throw a PropertyVetoException.
Use GenericCertificate.isLocked() to detect whether a
generic certificate has been successfuly signed or verified before
or call GenericCertificate.getContent() and expect an
Exception to be thrown if it hasn't.GenericCertificate if you
need an unlocked copy of the certificate.
certificate - the generic certificate used to hold the encoded
content and its digital signature.content - the object to sign. This must either be a JavaBean or an
instance of any other class which is supported by
{@link de.schlichtherle.xml.PersistenceService}
- maybe null.
Exception - for various reasons.
public GenericCertificate sign(Object content)
throws Exception
content and returns a locked
generic certificate holding the encoded content and its digital
signature.
Please note the following:
sign(GenericCertificate, Object) or
verify(GenericCertificate) is redundant
and will throw a PropertyVetoException.
Use GenericCertificate.isLocked() to detect whether a
generic certificate has been successfuly signed or verified before
or call GenericCertificate.getContent() and expect an
Exception to be thrown if it hasn't.GenericCertificate if you
need an unlocked copy of the certificate.
content - the object to sign. This must either be a JavaBean or an
instance of any other class which is supported by
PersistenceService
- maybe null.
Exception - for various reasons.
public void verify(GenericCertificate certificate)
throws Exception
certificate and locks it.
Please note the following:
PropertyVetoException if the
certificate is already locked, i.e. if it has been signed or
verified before.sign(GenericCertificate, Object) or
verify(GenericCertificate) is redundant
and will throw a PropertyVetoException.
Use GenericCertificate.isLocked() to detect whether a
generic certificate has been successfuly signed or verified before
or call GenericCertificate.getContent() and expect an
Exception to be thrown if it hasn't.GenericCertificate if you
need an unlocked copy of the certificate.
certificate - the generic certificate to verify
- may not be null.
Exception - a subclass of this class may be thrown for various
reasons.
|
TrueLicense Core 1.33 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||