org.idoox.xml.security
Class KeyContent

java.lang.Object
  extended byorg.idoox.xml.security.KeyContent
Direct Known Subclasses:
KeyValueContent

public abstract class KeyContent
extends java.lang.Object

Class represents content of the KeyInfo element and together with KeyContentFactory allows creating/verifying XML signature with application defined KeyInfo element. The implemented KeyContents are :

Example of creating and using application defined KeyContent:

      // create KeyContent class that extends KeyContent
      public class MyKeyContent extends KeyContent{
          public static final QName DUMMY_KEYCONTENT = new QName(
              "http://www.w3.org/2000/09/xmldsig#", "DummyKeyContent");
          public RSAKeyContent() {
                qname = DUMMY_KEYCONTENT;
            }
            
          ...
            
      }
      
      // register it to the KeyContentFactory
      KeyContentFactory.registerKeyContent(new MyKeyContent());
      ...
      
      // use KeyContent to create Signature:
      SignatureCreator creator = SignatureFactory.getInstance().getSignatureCreator();
      creator.setKeyContentData(DUMMY_KEYCONTENT, null); // needn't any additional data
      Tokenizer sign = creator.createSignature(...);
      
 

Component:
Security-Providers

Field Summary
static QName ALL_KEYCONTENTS
          When the properties are set for this QName, the propeties are valid for all KeyContent in the Signature.
protected  java.util.Map contentData
          This map holds all additional neccessary information to construct KeyContent object.
static QName DSA_KEYCONTENT
          name of the DSAKeyContent
static java.lang.String LICENSE_LOCATION_DEFFAULT_DOCUMENT
          When constructing a LicenseLocation KeyContent for verifying Signature, this property must be set to a Tokenizer object in the contentData map.
static QName LICENSE_LOCATION_KEYCONTENT
          name of the LicenseLocation KeyContent
static java.lang.String LICENSE_LOCATION_URI
          When constructing a LicenseLocation KeyContent for creating Signature, this property must be set to some URI in the contentData map.
static java.lang.String NO_CHECK_TRUSTED_CERTIFICATE
          When this property is set to true, verifier doesn't check whether the certificates in the signatures are trusted or not.
protected  QName qname
          qualified name of this object
static QName RSA_KEYCONTENT
          name of the RSAKeyContent
static QName X509CERTIFICATE_KEYCONTENT
          name of the CertificateKeyContent
 
Constructor Summary
KeyContent()
           
 
Method Summary
abstract  void construct(java.lang.Object keyData)
          Constructs KeyContent object from a given keyData that might be for example instance of java.security.PublicKey or java.security.cert.X509Certificate.
abstract  void construct(Tokenizer tokenizedKeyContent)
          Constructs KeyContentObject from a given tokenizer.
 java.util.Map getContentData()
          Returns the contentData member of this object.
 QName getName()
          Returns a qualified name of this object.
abstract  java.security.PublicKey getPublicKey()
          Returns a public key associated with this object.
abstract  KeyContent newInstance()
          Returns a new instance of the KeyContent.
 void setContentData(java.util.Map contentData)
          Sets a contentData member of this object to the given map.
abstract  java.lang.String toCanonicalXMLString(java.lang.String signaturePrefix)
          Returns the canonical xml representation of this KeyContent object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RSA_KEYCONTENT

public static final QName RSA_KEYCONTENT
name of the RSAKeyContent


DSA_KEYCONTENT

public static final QName DSA_KEYCONTENT
name of the DSAKeyContent


X509CERTIFICATE_KEYCONTENT

public static final QName X509CERTIFICATE_KEYCONTENT
name of the CertificateKeyContent


LICENSE_LOCATION_KEYCONTENT

public static final QName LICENSE_LOCATION_KEYCONTENT
name of the LicenseLocation KeyContent


ALL_KEYCONTENTS

public static final QName ALL_KEYCONTENTS
When the properties are set for this QName, the propeties are valid for all KeyContent in the Signature.


LICENSE_LOCATION_URI

public static final java.lang.String LICENSE_LOCATION_URI
When constructing a LicenseLocation KeyContent for creating Signature, this property must be set to some URI in the contentData map.

See Also:
Constant Field Values

NO_CHECK_TRUSTED_CERTIFICATE

public static final java.lang.String NO_CHECK_TRUSTED_CERTIFICATE
When this property is set to true, verifier doesn't check whether the certificates in the signatures are trusted or not. Trusted certificate is a certificate that is stored WSO2 SOA Enablement Server server PStore as trusted.

See Also:
Constant Field Values

LICENSE_LOCATION_DEFFAULT_DOCUMENT

public static final java.lang.String LICENSE_LOCATION_DEFFAULT_DOCUMENT
When constructing a LicenseLocation KeyContent for verifying Signature, this property must be set to a Tokenizer object in the contentData map.

See Also:
Constant Field Values

contentData

protected java.util.Map contentData
This map holds all additional neccessary information to construct KeyContent object. See method setContentData for further information.


qname

protected QName qname
qualified name of this object

Constructor Detail

KeyContent

public KeyContent()
Method Detail

construct

public abstract void construct(java.lang.Object keyData)
                        throws SignatureException
Constructs KeyContent object from a given keyData that might be for example instance of java.security.PublicKey or java.security.cert.X509Certificate.

Parameters:
keyData - an object that provides information about PublicKey.
Throws:
SignatureException - Exception

construct

public abstract void construct(Tokenizer tokenizedKeyContent)
                        throws SignatureException
Constructs KeyContentObject from a given tokenizer.

Parameters:
tokenizedKeyContent - a given tokenized KeyContent object.
Throws:
SignatureException - Exception

toCanonicalXMLString

public abstract java.lang.String toCanonicalXMLString(java.lang.String signaturePrefix)
                                               throws SignatureException
Returns the canonical xml representation of this KeyContent object.

Parameters:
signaturePrefix - prefix of the being created signature
Returns:
a String representation of this object.
Throws:
SignatureException - thrown when any error occurs.

getPublicKey

public abstract java.security.PublicKey getPublicKey()
                                              throws SignatureException
Returns a public key associated with this object.

Returns:
a public key associated with this object.
Throws:
SignatureException - Exception

newInstance

public abstract KeyContent newInstance()
Returns a new instance of the KeyContent.

Returns:
a new instance of the KeyContent

getName

public QName getName()
Returns a qualified name of this object. return a qualified name of this object.

Returns:
The Name value

setContentData

public void setContentData(java.util.Map contentData)
Sets a contentData member of this object to the given map. The contentData store all additional data, that is neccessary to construct KeyContent object. If KeyContent is RSAKeyValue or DSAKeyValue, there is no need to set any additional data. But if it is an instance of LicenseLocation the property LICENSE_LOCATION_URI must be set in the map.

Parameters:
contentData - a given map with additional data

getContentData

public java.util.Map getContentData()
Returns the contentData member of this object.

Returns:
the contentData member of this object.