Rice Pastry API

org.mpisws.p2p.transport.peerreview.identity
Class IdentityTransprotLayerImpl<Identifier,I>

java.lang.Object
  extended by org.mpisws.p2p.transport.table.TableTransprotLayerImpl<Identifier,I,java.security.cert.X509Certificate>
      extended by org.mpisws.p2p.transport.peerreview.identity.IdentityTransprotLayerImpl<Identifier,I>
All Implemented Interfaces:
HashProvider, CertificateManager<Identifier,I>, IdentityTransport<Identifier,I>, TableTransportLayer<Identifier,I,java.security.cert.X509Certificate>, TransportLayer<Identifier,java.nio.ByteBuffer>, TransportLayerCallback<Identifier,java.nio.ByteBuffer>, Destructable

public class IdentityTransprotLayerImpl<Identifier,I>
extends TableTransprotLayerImpl<Identifier,I,java.security.cert.X509Certificate>
implements IdentityTransport<Identifier,I>

TODO: make it store known certs to a file, make it periodically check the revocation server.

Author:
Jeff Hoye

Field Summary
static java.lang.String DEFAULT_SIGNATURE_ALGORITHM
           
 
Fields inherited from class org.mpisws.p2p.transport.table.TableTransprotLayerImpl
callback, errorHandler, keySerializer, knownValues, logger, PASSTHROUGH, REQUEST, RESPONSE_FAILED, RESPONSE_SUCCESS, tl, valueSerializer
 
Constructor Summary
IdentityTransprotLayerImpl(Serializer<I> iSerializer, X509Serializer cSerializer, I localId, java.security.cert.X509Certificate localCert, java.security.PrivateKey localPrivate, TransportLayer<Identifier,java.nio.ByteBuffer> tl, HashProvider hasher, Environment env)
           
 
Method Summary
 byte[] getEmptyHash()
           
 short getHashSizeBytes()
           
 java.security.Signature getVerifier(I i)
          Returns null if we don't know the cert for the identifier.
 boolean hasCertificate(I i)
           
 byte[] hash(java.nio.ByteBuffer... hashMe)
           
 byte[] hash(long seq, short type, byte[] nodeHash, byte[] contentHash)
           
 Cancellable requestCertificate(Identifier source, I principal, Continuation<java.security.cert.X509Certificate,java.lang.Exception> c, java.util.Map<java.lang.String,java.lang.Object> options)
          CERT_REQUEST, int requestId, Identifier
 byte[] sign(byte[] bytes)
           
 short signatureSizeInBytes()
           
 void verify(I id, byte[] msg, int moff, int mlen, byte[] signature, int soff, int slen)
           
 
Methods inherited from class org.mpisws.p2p.transport.table.TableTransprotLayerImpl
acceptMessages, acceptSockets, destroy, getLocalIdentifier, handleValueRequest, hasKey, incomingSocket, messageReceived, openSocket, requestValue, sendMessage, setCallback, setErrorHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mpisws.p2p.transport.TransportLayer
acceptMessages, acceptSockets, getLocalIdentifier, openSocket, sendMessage, setCallback, setErrorHandler
 
Methods inherited from interface rice.Destructable
destroy
 

Field Detail

DEFAULT_SIGNATURE_ALGORITHM

public static final java.lang.String DEFAULT_SIGNATURE_ALGORITHM
See Also:
Constant Field Values
Constructor Detail

IdentityTransprotLayerImpl

public IdentityTransprotLayerImpl(Serializer<I> iSerializer,
                                  X509Serializer cSerializer,
                                  I localId,
                                  java.security.cert.X509Certificate localCert,
                                  java.security.PrivateKey localPrivate,
                                  TransportLayer<Identifier,java.nio.ByteBuffer> tl,
                                  HashProvider hasher,
                                  Environment env)
                           throws java.security.InvalidKeyException,
                                  java.security.NoSuchAlgorithmException,
                                  java.security.NoSuchProviderException
Throws:
java.security.InvalidKeyException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
Method Detail

requestCertificate

public Cancellable requestCertificate(Identifier source,
                                      I principal,
                                      Continuation<java.security.cert.X509Certificate,java.lang.Exception> c,
                                      java.util.Map<java.lang.String,java.lang.Object> options)
CERT_REQUEST, int requestId, Identifier

Specified by:
requestCertificate in interface CertificateManager<Identifier,I>

hasCertificate

public boolean hasCertificate(I i)
Specified by:
hasCertificate in interface CertificateManager<Identifier,I>

sign

public byte[] sign(byte[] bytes)
Specified by:
sign in interface CertificateManager<Identifier,I>

verify

public void verify(I id,
                   byte[] msg,
                   int moff,
                   int mlen,
                   byte[] signature,
                   int soff,
                   int slen)
            throws java.security.InvalidKeyException,
                   java.security.NoSuchAlgorithmException,
                   java.security.NoSuchProviderException,
                   java.security.SignatureException,
                   UnknownCertificateException
Specified by:
verify in interface CertificateManager<Identifier,I>
Throws:
java.security.InvalidKeyException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
java.security.SignatureException
UnknownCertificateException

getVerifier

public java.security.Signature getVerifier(I i)
                                    throws java.security.NoSuchAlgorithmException,
                                           java.security.NoSuchProviderException,
                                           java.security.InvalidKeyException
Returns null if we don't know the cert for the identifier.

Parameters:
i -
Returns:
Throws:
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
java.security.InvalidKeyException

signatureSizeInBytes

public short signatureSizeInBytes()
Specified by:
signatureSizeInBytes in interface CertificateManager<Identifier,I>

getEmptyHash

public byte[] getEmptyHash()
Specified by:
getEmptyHash in interface HashProvider

getHashSizeBytes

public short getHashSizeBytes()
Specified by:
getHashSizeBytes in interface HashProvider

hash

public byte[] hash(long seq,
                   short type,
                   byte[] nodeHash,
                   byte[] contentHash)
Specified by:
hash in interface HashProvider

hash

public byte[] hash(java.nio.ByteBuffer... hashMe)
Specified by:
hash in interface HashProvider

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.