|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
ObjectXKMSContext
public abstract class XKMSContext
Start here :-)
This class is the main entrance point to the IAIK XKMS API.
The first thing as a client is to obtain an instance of XKMSContext
by means of the
XKMSContext.newInstance(...) method.
All further XKMS objects are created from this instance using create... style methods.
Thread safety
If a client of IAIK XKMS is multithreaded and multiple threads
want to use IAIK XKMS functionalities, there are a few points to remember:
- Use one XKMSContext instance per thread.
- Objects created by one XKMSContext can only be passed on to another
XKMSContext of identical subtype.
- If you want to use the same XKMS object in multiple
threads, e.g. share an Authentication object, it is your
responsibility to synchronize accesses to this object.
| Method Summary | |
|---|---|
abstract Authentication |
createAuthentication()
Creates a new Authentication object. |
abstract CompoundRequest |
createCompoundRequest()
Creates a new CompoundRequest, which is empty, except for a randomly generated ID. |
abstract CompoundResult |
createCompoundResult(XRequestAbstractType request)
Creates a new CompoundResult. |
abstract KeyBinding |
createKeyBinding()
Creates a new KeyBinding object. |
KeyInfo |
createKeyInfo()
Creates a new (empty) KeyInfo object. |
abstract LocateRequest |
createLocateRequest()
Creates a new LocateRequest, which is empty, except for a randomly generated ID. |
abstract LocateResult |
createLocateResult(XRequestAbstractType request)
Creates a new LocateResult. |
abstract PendingRequest |
createPendingRequest()
Creates a new PendingRequest, which is empty, except for a randomly generated ID. |
abstract PrototypeKeyBinding |
createPrototypeKeyBinding()
Creates a new PrototypeKeyBinding object. |
abstract QueryKeyBinding |
createQueryKeyBinding()
Creates a new QueryKeyBinding object. |
abstract RecoverKeyBinding |
createRecoverKeyBinding()
Creates a new RecoverKeyBinding object. |
abstract RecoverRequest |
createRecoverRequest()
Creates a new RecoverRequest, which is empty, except for a randomly generated ID. |
abstract RecoverResult |
createRecoverResult(XRequestAbstractType request)
Creates a new RecoverResult. |
abstract RegisterRequest |
createRegisterRequest()
Creates a new RegisterRequest, which is empty, except for a randomly generated ID. |
abstract RegisterResult |
createRegisterResult(XRequestAbstractType request)
Creates a new RegisterResult. |
abstract ReissueKeyBinding |
createReissueKeyBinding()
Creates a new ReissueKeyBinding object. |
abstract ReissueRequest |
createReissueRequest()
Creates a new ReissueRequest, which is empty, except for a randomly generated ID. |
abstract ReissueResult |
createReissueResult(XRequestAbstractType request)
Creates a new ReissueResult. |
abstract Result |
createResult(XRequestAbstractType request)
Creates a new Result. |
abstract RevokeKeyBinding |
createRevokeKeyBinding()
Creates a new RevokeKeyBinding object. |
abstract RevokeRequest |
createRevokeRequest()
Creates a new RevokeRequest, which is empty, except for a randomly generated ID. |
abstract RevokeResult |
createRevokeResult(XRequestAbstractType request)
Creates a new RevokeResult. |
abstract StatusRequest |
createStatusRequest()
Creates a new StatusRequest, which is empty, except for a randomly generated ID. |
abstract StatusResult |
createStatusResult(XRequestAbstractType request)
Creates a new StatusResult. |
abstract UnverifiedKeyBinding |
createUnverifiedKeyBinding()
Creates a new UnverifiedKeyBinding object. |
abstract ValidateRequest |
createValidateRequest()
Creates a new ValidateRequest, which is empty, except for a randomly generated ID. |
abstract ValidateResult |
createValidateResult(XRequestAbstractType request)
Creates a new ValidateResult. |
abstract XPrivateKey |
createXPrivateKey()
Creates a new XPrivateKey object. |
abstract XPrivateKey |
decryptPrivateKeyBlock(XKRSSResult message,
Key key)
Decrypts and returns the encrypted private key of this result message. |
abstract XMessageAbstractType |
DOMToMessage(Element startelement)
Converts DOM tree to XKMS message. |
static void |
DOMToStream(Document doc,
OutputStream os)
Outputs a DOM Document to an OutputStream. |
static String |
DOMToString(Document document)
Converts a DOM document into a String. |
int |
getIdLength()
Gets default number of characters for generated message Id. |
X509Certificate |
getMessageCertificate()
Gets the default certificate of newly created messages. |
PrivateKey |
getMessagePrivateKey()
Gets the default signature private key of newly created messages. |
int |
getNonceLength()
Gets default number of characters for generated message nonce. |
String |
getServiceURI()
Get default ServiceURI of messages. |
String |
getType()
Gets subtype of XKMSContext instance. |
abstract Document |
MessageToDOM(XMessageAbstractType message)
Converts XKMS message to DOM tree. |
void |
MessageToStream(XMessageAbstractType message,
OutputStream os)
Outputs a message to an OutputStream. |
String |
MessageToString(XMessageAbstractType message)
Converts a message into a String. |
static XKMSContext |
newInstance(String type)
Create a new custom tuned instance of XKMSContext. |
void |
setIdLength(int length)
Sets default number of characters for generated message Id. |
void |
setMessageCredentials(X509Certificate cert,
PrivateKey privkey)
Set default credentials to use for global message signature. |
void |
setNonceLength(int length)
Sets default number of characters for generated message nonce. |
void |
setRandomId(XMessageAbstractType message)
Sets the Id attribute of a message to a random value. |
void |
setRandomNonce(XMessageAbstractType message)
Sets the Nonce of a message to a random value. |
void |
setServiceURI(String servicename)
Sets default ServiceURI of messages. |
Document |
StreamToDOM(InputStream stream)
Parses XML from InputStream and returns a DOM representation. |
XMessageAbstractType |
StreamToMessage(InputStream stream)
Converts an InputStream into a Message. |
Document |
StringToDOM(String string)
Parses XML from String and returns a DOM representation. |
XMessageAbstractType |
StringToMessage(String message)
Converts a String into a Message. |
abstract boolean |
validateKeyBindingAuthenticationSignature(XKRSSRequest message,
Key key)
Validates KeyBindingAuthentication signature with the supplied key. |
abstract boolean |
validateProofOfPossessionSignature(XKRSSRequest message,
Key key)
Validates ProofOfPossession signature with the supplied key. |
abstract boolean |
validateSignature(XMessageAbstractType message,
Key key)
Validates global message signature with supplied public key. |
| Methods inherited from class Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static XKMSContext newInstance(String type)
throws XKMSException
type - A string of format "marshaller:xmlprovider" which specifies which
lowlevel implementation to use.
Valid values for marshaller:
JAXB - JAXB 2.0 marshalling autogenerated from XKMS schema.
Valid values for xmlprovider:
IAIK - use IAIK JCE and XSECT libraries (=maximum functionality).
JWSDP - use JWSDP (=Apache) xmlsec libraries (=reduced fuctionality).
Or pass null for autodetection.
XKMSException - if something goes wrong.public String getType()
String description of XKMSContext subtype.
public static void DOMToStream(Document doc,
OutputStream os)
throws XKMSException
OutputStream. (e.g. System.out)
doc - DOM document which should be output to Streamos - Stream to write result to
XKMSException - if something goes wrong.
public static String DOMToString(Document document)
throws XKMSException
String.
document - DOM document which should be converted into a String
XKMSException - if something goes wrong.
public String MessageToString(XMessageAbstractType message)
throws XKMSException
String.
message - which should be converted into a String
XKMSException - if something goes wrong.
public void MessageToStream(XMessageAbstractType message,
OutputStream os)
throws XKMSException
OutputStream. (e.g. System.out)
message - which should be output to Streamos - Stream to write result to
XKMSException - if something goes wrong.
public XMessageAbstractType StringToMessage(String message)
throws XKMSException
String into a Message.
message - String which should be converted into a message
String
XKMSException - if something goes wrong.
public XMessageAbstractType StreamToMessage(InputStream stream)
throws XKMSException
InputStream into a Message.
stream - InputStream which contains the message to read from
Inputstream
XKMSException - if something goes wrong.
public Document StreamToDOM(InputStream stream)
throws XKMSException
stream - InputStream to read from
Document containing the XML read from
stream
XKMSException - if something goes wrong
public Document StringToDOM(String string)
throws XKMSException
string - String to parse from
Document containing the XML read from
String
XKMSException - if something goes wrong
public abstract XMessageAbstractType DOMToMessage(Element startelement)
throws XKMSException
startelement - root element of the Message (so if there is only one
message in the DOM this is Document.getDocumentElement()).
XKMSException - if something goes wrong.
public abstract Document MessageToDOM(XMessageAbstractType message)
throws XKMSException
message - message to convert
XKMSException - if something goes wrong.public abstract LocateRequest createLocateRequest()
LocateRequest, which is empty, except for a randomly generated ID.
LocateRequestpublic abstract ValidateRequest createValidateRequest()
ValidateRequest, which is empty, except for a randomly generated ID.
ValidatRequestpublic abstract RegisterRequest createRegisterRequest()
RegisterRequest, which is empty, except for a randomly generated ID.
RegisterRequestpublic abstract ReissueRequest createReissueRequest()
ReissueRequest, which is empty, except for a randomly generated ID.
ReissueRequestpublic abstract RecoverRequest createRecoverRequest()
RecoverRequest, which is empty, except for a randomly generated ID.
RecoverRequestpublic abstract RevokeRequest createRevokeRequest()
RevokeRequest, which is empty, except for a randomly generated ID.
RevokeRequestpublic abstract StatusRequest createStatusRequest()
StatusRequest, which is empty, except for a randomly generated ID.
StatusRequestpublic abstract PendingRequest createPendingRequest()
PendingRequest, which is empty, except for a randomly generated ID.
PendingRequestpublic abstract CompoundRequest createCompoundRequest()
CompoundRequest, which is empty, except for a randomly generated ID.
CompoundRequestpublic abstract CompoundResult createCompoundResult(XRequestAbstractType request)
CompoundResult.
A random ID will be automatically created and set.
Furthermore, if the request parameter is not null
then also the data of the request will be transferred, if applicable.
request - request to get data from or null
public abstract StatusResult createStatusResult(XRequestAbstractType request)
StatusResult.
A random ID will be automatically created and set.
Furthermore, if the request parameter is not null
then also the data of the request will be transferred, if applicable.
request - request to get data from or null
public abstract Result createResult(XRequestAbstractType request)
Result.
A random ID will be automatically created and set.
Furthermore, if the request parameter is not null
then also the data of the request will be transferred, if applicable.
request - request to get data from or null
public abstract LocateResult createLocateResult(XRequestAbstractType request)
LocateResult.
A random ID will be automatically created and set.
Furthermore, if the request parameter is not null
then also the data of the request will be transferred, if applicable.
request - request to get data from or null
public abstract ValidateResult createValidateResult(XRequestAbstractType request)
ValidateResult.
A random ID will be automatically created and set.
Furthermore, if the request parameter is not null
then also the data of the request will be transferred, if applicable.
request - request to get data from or null
public abstract ReissueResult createReissueResult(XRequestAbstractType request)
ReissueResult.
A random ID will be automatically created and set.
Furthermore, if the request parameter is not null
then also the data of the request will be transferred, if applicable.
request - request to get data from or null
public abstract RevokeResult createRevokeResult(XRequestAbstractType request)
RevokeResult.
A random ID will be automatically created and set.
Furthermore, if the request parameter is not null
then also the data of the request will be transferred, if applicable.
request - request to get data from or null
public abstract RecoverResult createRecoverResult(XRequestAbstractType request)
RecoverResult.
A random ID will be automatically created and set.
Furthermore, if the request parameter is not null
then also the data of the request will be transferred, if applicable.
request - request to get data from or null
public abstract RegisterResult createRegisterResult(XRequestAbstractType request)
RegisterResult.
A random ID will be automatically created and set.
Furthermore, if the request parameter is not null
then also the data of the request will be transferred, if applicable.
request - request to get data from or null
public abstract Authentication createAuthentication()
Authentication object.
Authentication object.public abstract UnverifiedKeyBinding createUnverifiedKeyBinding()
UnverifiedKeyBinding object.
UnverifiedKeyBinding object.public abstract KeyBinding createKeyBinding()
KeyBinding object.
KeyBinding object.public abstract PrototypeKeyBinding createPrototypeKeyBinding()
PrototypeKeyBinding object.
PrototypeKeyBinding object.public abstract QueryKeyBinding createQueryKeyBinding()
QueryKeyBinding object.
QueryKeyBinding object.public abstract RevokeKeyBinding createRevokeKeyBinding()
RevokeKeyBinding object.
RevokeKeyBinding object.public abstract RecoverKeyBinding createRecoverKeyBinding()
RecoverKeyBinding object.
RecoverKeyBinding object.public abstract ReissueKeyBinding createReissueKeyBinding()
ReissueKeyBinding object.
ReissueKeyBinding object.public abstract XPrivateKey createXPrivateKey()
XPrivateKey object.
XPrivateKey object.public KeyInfo createKeyInfo()
KeyInfo object.
KeyInfo object.
public abstract boolean validateProofOfPossessionSignature(XKRSSRequest message,
Key key)
throws XKMSException
ProofOfPossession signature with the supplied key.
Before calling this validate method, ensure by calling message.hasProofOfPossessionSignature() that the message contains a PoP signature at all, otherwise result of this call is undefined.
message - request message containing a PoP signaturekey - key to use for validation
true if the ProofOfPossession signature
validates, false otherwise
XKMSException - if supplied message is not a RegisterRequest
or ReissueRequest (the only messages capable of carrying a
ProofOfPossession signature)
public abstract boolean validateKeyBindingAuthenticationSignature(XKRSSRequest message,
Key key)
throws XKMSException
KeyBindingAuthentication signature with the supplied key.
Before calling this validate method, ensure by calling message.hasKeyBindingAuthenticationSignature() that the message contains a KeyBinding Authentication signature at all, otherwise result of this call is undefined.
message - request message containing a KBauth signaturekey - key to use for validation
true if the KeyBindingAuthentication signature
is valid, false otherwise
XKMSException - if supplied message is not a RegisterRequest,
ReissueRequest, RevokeRequest or RecoverRequest
(the only messages capable of carrying a KBauth signature)
public abstract boolean validateSignature(XMessageAbstractType message,
Key key)
Before calling this validate method, ensure by calling message.hasSignature() that the message contains a global signature at all, otherwise result of this call is undefined.
key - the key to be used for signature verification
true if, and only if the signature is valid.
public abstract XPrivateKey decryptPrivateKeyBlock(XKRSSResult message,
Key key)
throws XKMSException
The supplied key will be used to perform decryption.
Before calling this decrypt method, ensure by calling message.hasPrivateKeyBlock() that the message contains an encrypted PrivateKey block at all, otherwise result of this call is undefined.
message - result message containing an encrypted PrivateKey block.key - key to use for decryption
PrivateKey
XKMSException - if supplied message is not a RegisterResult,
or RecoverResult
(the only messages capable of carrying an encrypted PrivateKey).
Also, if a null key is supplied.public X509Certificate getMessageCertificate()
null.public PrivateKey getMessagePrivateKey()
null.
public void setMessageCredentials(X509Certificate cert,
PrivateKey privkey)
null the
message will be signed with supplied private key.
If additionally the certificate is not null, it will be
included in the signature, too.
privkey - private key which will be used to sign every messagecert - certificate containing public key corresponding to private keypublic String getServiceURI()
public void setServiceURI(String servicename)
null no default is set.
servicename - the URI of the servicepublic int getNonceLength()
public void setNonceLength(int length)
throws BadParameterException
length - number of characters of nonce
BadParameterException - if less than 32 specified, which is the minimum for security reasonspublic void setRandomNonce(XMessageAbstractType message)
Nonce of a message to a random value.
message - message to set Nonce inpublic int getIdLength()
public void setIdLength(int length)
throws BadParameterException
length - number of chars of Id
BadParameterException - if less than 32 specified, which is the minimum entropy for security reasonspublic void setRandomId(XMessageAbstractType message)
Id attribute of a message to a random value.
message - message to set Id in
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||