Project JXTA

net.jxta.impl.membership.pse
Class PSECredential

java.lang.Object
  extended bynet.jxta.impl.membership.pse.PSECredential
All Implemented Interfaces:
Credential, CredentialPCLSupport

public final class PSECredential
extends Object
implements Credential, CredentialPCLSupport

This class provides the sub-class of Credential which is associated with the PSE membership service.

There are two varients of the credential:

The schema for this credential format:


  <xs:element name="PSECred" type="jxta:PSECred" />

  <xs:complexType name="PSECred">
    <xs:sequence>
      <xs:element name="PeerGroupID" type="jxta:JXTAID" />
      <xs:element name="PeerID" type="jxta:JXTAID" />
      <!-- An X.509 Certificate -->
      <xs:element name="Certificate" type="xs:string" minOccurs="1" maxOccurs="unbounded" />
      <!-- A SHA1WithRSA Signature -->
      <xs:element name="Signature" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
  </code>

See Also:
Credential, PSEMembershipService

Constructor Summary
  PSECredential(Element root)
          Create a new remote credential.
  PSECredential(PSEMembershipService source, Element root)
          Create a new remote credential.
protected PSECredential(PSEMembershipService source, ID keyID, CertPath certChain, PrivateKey privateKey)
          Create a new local credential.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add a listener
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Add a listener
 boolean equals(Object target)
          
protected  void finalize()
          
 X509Certificate getCertificate()
          Returns the certificate associated with this credential.
 X509Certificate[] getCertificateChain()
          Returns the certificate chain associated with this credential.
 StructuredDocument getDocument(MimeMediaType encodeAs)
          
 ID getKeyID()
          Returns the key id associated with this credential, if any.
 ID getPeerGroupID()
          
 ID getPeerID()
          
 PrivateKey getPrivateKey()
          Deprecated. Use <@link #getSigner(String)> or <@link #getSignatureVerifier(String)> instead.
 Signature getSignatureVerifier(String algorithm)
          Get a Signature verifier object based upon the certificate associated with this credential.
 Signature getSigner(String algorithm)
          Get a Signature object based upon the private key associated with this credential.
 Service getSourceService()
          
 Object getSubject()
          
protected  boolean handleElement(XMLElement elem)
          Process an individual element from the document.
 int hashCode()
          
protected  void initialize(Element root)
          Intialize from a portion of a structured document.
 boolean isExpired()
          

A PSE Credential is valid as long as the associated certificate is valid.

 boolean isValid()
          

A PSE Credential is valid as long as the associated certificate is valid and as long as the membership service still has the credential.

 void removePropertyChangeListener(PropertyChangeListener listener)
          Remove a listener
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Remove a listener
(package private)  void setValid(boolean valid)
          {@inheritDoc}

A PSE Credential is valid as long as the associated certificate is valid.

 String toString()
          
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PSECredential

protected PSECredential(PSEMembershipService source,
                        ID keyID,
                        CertPath certChain,
                        PrivateKey privateKey)
                 throws IOException
Create a new local credential. This credential can be used for signing and can be serialized.


PSECredential

public PSECredential(Element root)
Create a new remote credential. This credential cannot be used for signing and cannot be re-serialized.


PSECredential

public PSECredential(PSEMembershipService source,
                     Element root)
Create a new remote credential. This credential cannot be used for signing and cannot be re-serialized.

Method Detail

equals

public boolean equals(Object target)


finalize

protected void finalize()
                 throws Throwable

Throws:
Throwable

hashCode

public int hashCode()


toString

public String toString()


addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Add a listener

Specified by:
addPropertyChangeListener in interface CredentialPCLSupport
Parameters:
listener - the listener

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Add a listener

Specified by:
addPropertyChangeListener in interface CredentialPCLSupport
Parameters:
propertyName - the property to watch
listener - the listener

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a listener

Specified by:
removePropertyChangeListener in interface CredentialPCLSupport
Parameters:
listener - the listener

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Remove a listener

Specified by:
removePropertyChangeListener in interface CredentialPCLSupport
Parameters:
propertyName - the property which was watched
listener - the listener

getPeerGroupID

public ID getPeerGroupID()

Specified by:
getPeerGroupID in interface Credential

getPeerID

public ID getPeerID()

Specified by:
getPeerID in interface Credential

isExpired

public boolean isExpired()

A PSE Credential is valid as long as the associated certificate is valid.

Specified by:
isExpired in interface Credential

isValid

public boolean isValid()

A PSE Credential is valid as long as the associated certificate is valid and as long as the membership service still has the credential.

Specified by:
isValid in interface Credential

setValid

void setValid(boolean valid)
{@inheritDoc}

A PSE Credential is valid as long as the associated certificate is valid.


getSubject

public Object getSubject()

Specified by:
getSubject in interface Credential

getSourceService

public Service getSourceService()

Specified by:
getSourceService in interface Credential

getDocument

public StructuredDocument getDocument(MimeMediaType encodeAs)
                               throws Exception

Specified by:
getDocument in interface Credential
Throws:
Exception

getCertificate

public X509Certificate getCertificate()
Returns the certificate associated with this credential.

Returns:
the certificate associated with this credential.

getCertificateChain

public X509Certificate[] getCertificateChain()
Returns the certificate chain associated with this credential.

Returns:
the certificate chain associated with this credential.

getPrivateKey

public PrivateKey getPrivateKey()
Deprecated. Use <@link #getSigner(String)> or <@link #getSignatureVerifier(String)> instead.

Returns the private key associated with this credential. Only valid for locally generated credentials.

Returns:
the private key associated with this credential.

getKeyID

public ID getKeyID()
Returns the key id associated with this credential, if any. Only locally generated credentials have a key ID.

Returns:
Returns the key id associated with this credential, if any.

getSigner

public Signature getSigner(String algorithm)
                    throws NoSuchAlgorithmException
Get a Signature object based upon the private key associated with this credential.

Parameters:
algorithm - the signing algorithm to use.
Returns:
Signature.
Throws:
NoSuchAlgorithmException

getSignatureVerifier

public Signature getSignatureVerifier(String algorithm)
                               throws NoSuchAlgorithmException
Get a Signature verifier object based upon the certificate associated with this credential.

Parameters:
algorithm - the signing algorithm to use.
Returns:
Signature.
Throws:
NoSuchAlgorithmException

handleElement

protected boolean handleElement(XMLElement elem)
Process an individual element from the document.

Parameters:
elem - the element to be processed.
Returns:
true if the element was recognized, otherwise false.

initialize

protected void initialize(Element root)
Intialize from a portion of a structured document.


JXTA J2SE