|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mpisws.p2p.transport.peerreview.PeerReviewImpl<Handle,Identifier>
Handle
- (Usually a NodeHandle)Identifier
- (Permanent Identifier), can get an Identifier from a Handlepublic class PeerReviewImpl<Handle extends RawSerializable,Identifier extends RawSerializable>
Fields inherited from interface org.mpisws.p2p.transport.peerreview.PeerReview |
---|
DONT_COMMIT, PEER_REVIEW_COMMIT, PEER_REVIEW_PASSTHROUGH, RELEVANT_LENGTH |
Fields inherited from interface org.mpisws.p2p.transport.peerreview.StatusConstants |
---|
STATUS_EXPOSED, STATUS_SUSPECTED, STATUS_TRUSTED |
Constructor Summary | |
---|---|
PeerReviewImpl(IdentityTransport<Handle,Identifier> transport,
Environment env,
Serializer<Handle> handleSerializer,
Serializer<Identifier> idSerializer,
IdentifierExtractor<Handle,Identifier> identifierExtractor,
IdStrTranslator<Identifier> stringTranslator)
|
Method Summary | |
---|---|
void |
acceptMessages(boolean b)
Toggle accepting incoming messages. |
void |
acceptSockets(boolean b)
Toggle accepting new sockets. |
boolean |
addAuthenticatorIfValid(AuthenticatorStore<Identifier> store,
Identifier subject,
Authenticator auth)
Helper function called internally from the library. |
void |
challengeSuspectedNode(Handle handle)
|
void |
destroy()
|
protected void |
doAuthPush()
Periodic timer for pushing batches of authenticators to the witnesses |
protected void |
doCheckpoint()
Periodic timer for writing checkpoints |
protected void |
doMaintenance()
Periodic maintenance timer; used to garbage-collect old authenticators |
Authenticator |
extractAuthenticator(Identifier id,
long seq,
short entryType,
byte[] entryHash,
byte[] hTopMinusOne,
byte[] signature)
|
Authenticator |
extractAuthenticator(long seq,
short entryType,
byte[] entryHash,
byte[] hTopMinusOne,
byte[] signature)
A helper function that extracts an authenticator from an incoming message and adds it to our local store. |
PeerReviewCallback<Handle,Identifier> |
getApp()
|
AuthenticatorSerializer |
getAuthenticatorSerializer()
|
byte[] |
getEmptyHash()
|
Environment |
getEnvironment()
|
long |
getEvidenceSeq()
|
EvidenceSerializer |
getEvidenceSerializer()
|
EvidenceTool<Handle,Identifier> |
getEvidenceTool()
|
Serializer<Handle> |
getHandleSerializer()
|
short |
getHashSizeBytes()
|
int |
getHashSizeInBytes()
|
SecureHistory |
getHistory()
|
SecureHistoryFactory |
getHistoryFactory()
|
IdentifierExtractor<Handle,Identifier> |
getIdentifierExtractor()
|
Serializer<Identifier> |
getIdSerializer()
|
Handle |
getLocalHandle()
|
Identifier |
getLocalId()
|
Handle |
getLocalIdentifier()
The local node. |
RandomSource |
getRandomSource()
|
protected SecureHistoryFactory |
getSecureHistoryFactory(IdentityTransport<Handle,Identifier> transport,
Environment env)
|
short |
getSignatureSizeBytes()
|
int |
getSignatureSizeInBytes()
|
static java.lang.String |
getStatusString(int status)
|
long |
getTime()
Current time in millis, however, we depend on there being a timesource that is more discritized than the "wall" clock. |
long |
getTimeToleranceMillis()
|
VerifierFactory<Handle,Identifier> |
getVerifierFactory()
|
boolean |
hasCertificate(Identifier id)
|
byte[] |
hash(java.nio.ByteBuffer... hashMe)
|
byte[] |
hash(long seq,
short type,
byte[] nodeHash,
byte[] contentHash)
|
void |
incomingSocket(P2PSocket<Handle> s)
Notification of a new socket. |
void |
init(java.lang.String dirname)
|
void |
messageReceived(Handle handle,
java.nio.ByteBuffer message,
java.util.Map<java.lang.String,java.lang.Object> options)
Called when a new message is received. |
void |
notifyCertificateAvailable(Identifier id)
|
void |
notifyStatusChange(Identifier id,
int newStatus)
|
SocketRequestHandle<Handle> |
openSocket(Handle i,
SocketCallback<Handle> deliverSocketToMe,
java.util.Map<java.lang.String,java.lang.Object> options)
Open a socket to the Identifier |
Cancellable |
requestCertificate(Handle source,
Identifier certHolder)
|
Cancellable |
requestCertificate(Handle source,
Identifier certHolder,
Continuation<java.security.cert.X509Certificate,java.lang.Exception> c,
java.util.Map<java.lang.String,java.lang.Object> options)
|
void |
sendEvidence(Handle dest,
Identifier evidenceAgainst)
|
void |
sendEvidenceToWitnesses(Identifier subject,
long evidenceSeq,
Evidence evidence)
Called internally by other classes if they have found evidence against one of our peers. |
MessageRequestHandle<Handle,java.nio.ByteBuffer> |
sendMessage(Handle target,
java.nio.ByteBuffer message,
MessageCallback<Handle,java.nio.ByteBuffer> deliverAckToMe,
java.util.Map<java.lang.String,java.lang.Object> options)
Send the message to the identifier |
void |
setApp(PeerReviewCallback<Handle,Identifier> callback)
|
void |
setCallback(TransportLayerCallback<Handle,java.nio.ByteBuffer> callback)
Set the callback for incoming sockets/messages |
void |
setErrorHandler(ErrorHandler<Handle> handler)
To be notified of problems not related to an outgoing messaage/socket. |
void |
setTimeToleranceMillis(long timeToleranceMicros)
PeerReview checks the timestamps on messages against the local clock, and ignores them if the timestamp is too far out of sync. |
byte[] |
sign(byte[] bytes)
|
void |
transmit(Handle dest,
PeerReviewMessage message,
MessageCallback<Handle,java.nio.ByteBuffer> deliverAckToMe,
java.util.Map<java.lang.String,java.lang.Object> options)
Note, must include PEER_REVIEW_COMMIT and the type |
protected void |
updateLogTime()
|
boolean |
verify(Identifier id,
Authenticator auth)
Throws exception if called w/o the cert for the subject |
int |
verify(Identifier id,
byte[] msg,
byte[] signature)
|
void |
writeCheckpoint()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected PeerReviewCallback<Handle extends RawSerializable,Identifier extends RawSerializable> callback
protected IdentityTransport<Handle extends RawSerializable,Identifier extends RawSerializable> transport
protected Serializer<Handle extends RawSerializable> handleSerializer
protected Serializer<Identifier extends RawSerializable> idSerializer
protected IdentifierExtractor<Handle extends RawSerializable,Identifier extends RawSerializable> identifierExtractor
protected IdStrTranslator<Identifier extends RawSerializable> stringTranslator
protected EvidenceSerializer evidenceSerializer
protected AuthenticatorSerializer authenticatorSerialilzer
protected EvidenceTool<Handle extends RawSerializable,Identifier extends RawSerializable> evidenceTool
protected Environment env
protected Logger logger
protected AuthenticatorStore<Identifier extends RawSerializable> authInStore
protected AuthenticatorStore<Identifier extends RawSerializable> authOutStore
protected AuthenticatorStore<Identifier extends RawSerializable> authCacheStore
protected AuthenticatorStore<Identifier extends RawSerializable> authPendingStore
protected PeerInfoStore<Handle extends RawSerializable,Identifier extends RawSerializable> infoStore
protected SecureHistoryFactory historyFactory
protected SecureHistory history
protected VerifierFactory<Handle extends RawSerializable,Identifier extends RawSerializable> verifierFactory
protected CommitmentProtocol<Handle extends RawSerializable,Identifier extends RawSerializable> commitmentProtocol
protected EvidenceTransferProtocol<Handle extends RawSerializable,Identifier extends RawSerializable> evidenceTransferProtocol
protected AuthenticatorPushProtocol<Handle extends RawSerializable,Identifier extends RawSerializable> authPushProtocol
protected AuditProtocol<Handle extends RawSerializable,Identifier extends RawSerializable> auditProtocol
protected ChallengeResponseProtocol<Handle extends RawSerializable,Identifier extends RawSerializable> challengeProtocol
protected StatementProtocolImpl<Handle extends RawSerializable,Identifier extends RawSerializable> statementProtocol
protected RandomSource random
protected long timeToleranceMillis
Constructor Detail |
---|
public PeerReviewImpl(IdentityTransport<Handle,Identifier> transport, Environment env, Serializer<Handle> handleSerializer, Serializer<Identifier> idSerializer, IdentifierExtractor<Handle,Identifier> identifierExtractor, IdStrTranslator<Identifier> stringTranslator)
Method Detail |
---|
public RandomSource getRandomSource()
getRandomSource
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
protected SecureHistoryFactory getSecureHistoryFactory(IdentityTransport<Handle,Identifier> transport, Environment env)
public void setTimeToleranceMillis(long timeToleranceMicros)
public long getEvidenceSeq()
getEvidenceSeq
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
protected void updateLogTime()
public MessageRequestHandle<Handle,java.nio.ByteBuffer> sendMessage(Handle target, java.nio.ByteBuffer message, MessageCallback<Handle,java.nio.ByteBuffer> deliverAckToMe, java.util.Map<java.lang.String,java.lang.Object> options)
TransportLayer
sendMessage
in interface TransportLayer<Handle extends RawSerializable,java.nio.ByteBuffer>
target
- the destinationmessage
- the messagedeliverAckToMe
- layer dependent notification when the message is sent (can indicate placed on the wire, point-to-point acknowledgment, or end-to-end acknowledgement)options
- delivery options (don't source route, encrypt etc) (may not be respected if layer cannot provide service)
public void setApp(PeerReviewCallback<Handle,Identifier> callback)
setApp
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public void setCallback(TransportLayerCallback<Handle,java.nio.ByteBuffer> callback)
TransportLayer
setCallback
in interface TransportLayer<Handle extends RawSerializable,java.nio.ByteBuffer>
callback
- the callback for incoming sockets/messagespublic void messageReceived(Handle handle, java.nio.ByteBuffer message, java.util.Map<java.lang.String,java.lang.Object> options) throws java.io.IOException
TransportLayerCallback
messageReceived
in interface TransportLayerCallback<Handle extends RawSerializable,java.nio.ByteBuffer>
handle
- The node it is coming frommessage
- the messageoptions
- describe how the message arrived (udp/tcp, encrypted etc)
java.io.IOException
- if there is a problem decoding the messagepublic static java.lang.String getStatusString(int status)
public boolean addAuthenticatorIfValid(AuthenticatorStore<Identifier> store, Identifier subject, Authenticator auth)
addAuthenticatorIfValid
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public Cancellable requestCertificate(Handle source, Identifier certHolder, Continuation<java.security.cert.X509Certificate,java.lang.Exception> c, java.util.Map<java.lang.String,java.lang.Object> options)
requestCertificate
in interface CertificateManager<Handle extends RawSerializable,Identifier extends RawSerializable>
public Cancellable requestCertificate(Handle source, Identifier certHolder)
requestCertificate
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public void notifyCertificateAvailable(Identifier id)
notifyCertificateAvailable
in interface IdentityTransportCallback<Handle extends RawSerializable,Identifier extends RawSerializable>
public void writeCheckpoint() throws java.io.IOException
java.io.IOException
protected void doAuthPush()
protected void doMaintenance()
protected void doCheckpoint()
public void notifyStatusChange(Identifier id, int newStatus)
notifyStatusChange
in interface StatusChangeListener<Identifier extends RawSerializable>
public void init(java.lang.String dirname) throws java.io.IOException
init
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
java.io.IOException
public PeerReviewCallback<Handle,Identifier> getApp()
getApp
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public SocketRequestHandle<Handle> openSocket(Handle i, SocketCallback<Handle> deliverSocketToMe, java.util.Map<java.lang.String,java.lang.Object> options)
TransportLayer
openSocket
in interface TransportLayer<Handle extends RawSerializable,java.nio.ByteBuffer>
i
- who to open the socket todeliverSocketToMe
- the callback when the socket is openedoptions
- options on how to open the socket (don't source route, encrypt etc) (may not be respected if layer cannot provide service)
public void incomingSocket(P2PSocket<Handle> s) throws java.io.IOException
TransportLayerCallback
incomingSocket
in interface TransportLayerCallback<Handle extends RawSerializable,java.nio.ByteBuffer>
s
- the incoming socket
java.io.IOException
public void acceptMessages(boolean b)
TransportLayer
acceptMessages
in interface TransportLayer<Handle extends RawSerializable,java.nio.ByteBuffer>
public void acceptSockets(boolean b)
TransportLayer
acceptSockets
in interface TransportLayer<Handle extends RawSerializable,java.nio.ByteBuffer>
public Identifier getLocalId()
getLocalId
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public Handle getLocalHandle()
getLocalHandle
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public Handle getLocalIdentifier()
TransportLayer
getLocalIdentifier
in interface TransportLayer<Handle extends RawSerializable,java.nio.ByteBuffer>
public void setErrorHandler(ErrorHandler<Handle> handler)
TransportLayer
setErrorHandler
in interface TransportLayer<Handle extends RawSerializable,java.nio.ByteBuffer>
handler
- to be notified of problems not related to a specific messaage/socket.public void destroy()
destroy
in interface Destructable
public AuthenticatorSerializer getAuthenticatorSerializer()
getAuthenticatorSerializer
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public Environment getEnvironment()
getEnvironment
in interface IdentityTransport<Handle extends RawSerializable,Identifier extends RawSerializable>
getEnvironment
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public Serializer<Identifier> getIdSerializer()
getIdSerializer
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public long getTime()
PeerReview
getTime
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public Authenticator extractAuthenticator(long seq, short entryType, byte[] entryHash, byte[] hTopMinusOne, byte[] signature)
extractAuthenticator
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public Authenticator extractAuthenticator(Identifier id, long seq, short entryType, byte[] entryHash, byte[] hTopMinusOne, byte[] signature)
extractAuthenticator
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public Serializer<Handle> getHandleSerializer()
getHandleSerializer
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public int getHashSizeInBytes()
getHashSizeInBytes
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public int getSignatureSizeInBytes()
getSignatureSizeInBytes
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public IdentifierExtractor<Handle,Identifier> getIdentifierExtractor()
getIdentifierExtractor
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public void challengeSuspectedNode(Handle handle)
challengeSuspectedNode
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public void sendEvidenceToWitnesses(Identifier subject, long evidenceSeq, Evidence evidence)
sendEvidenceToWitnesses
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
subject
- the "bad" guypublic void transmit(Handle dest, PeerReviewMessage message, MessageCallback<Handle,java.nio.ByteBuffer> deliverAckToMe, java.util.Map<java.lang.String,java.lang.Object> options)
transmit
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
dest
- message
- deliverAckToMe
- options
- public boolean hasCertificate(Identifier id)
hasCertificate
in interface CertificateManager<Handle extends RawSerializable,Identifier extends RawSerializable>
hasCertificate
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public byte[] sign(byte[] bytes)
sign
in interface CertificateManager<Handle extends RawSerializable,Identifier extends RawSerializable>
public short getSignatureSizeBytes()
getSignatureSizeBytes
in interface CertificateManager<Handle extends RawSerializable,Identifier extends RawSerializable>
public boolean verify(Identifier id, Authenticator auth)
PeerReview
verify
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public int verify(Identifier id, byte[] msg, byte[] signature)
verify
in interface CertificateManager<Handle extends RawSerializable,Identifier extends RawSerializable>
public byte[] getEmptyHash()
getEmptyHash
in interface HashProvider
public short getHashSizeBytes()
getHashSizeBytes
in interface HashProvider
public byte[] hash(long seq, short type, byte[] nodeHash, byte[] contentHash)
hash
in interface HashProvider
public byte[] hash(java.nio.ByteBuffer... hashMe)
hash
in interface HashProvider
public EvidenceSerializer getEvidenceSerializer()
public EvidenceTool<Handle,Identifier> getEvidenceTool()
getEvidenceTool
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public SecureHistoryFactory getHistoryFactory()
getHistoryFactory
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public VerifierFactory<Handle,Identifier> getVerifierFactory()
getVerifierFactory
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public SecureHistory getHistory()
getHistory
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public long getTimeToleranceMillis()
getTimeToleranceMillis
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
public void sendEvidence(Handle dest, Identifier evidenceAgainst)
sendEvidence
in interface PeerReview<Handle extends RawSerializable,Identifier extends RawSerializable>
|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |