LimeWire Consolidated API

org.limewire.security
Class AbstractSecurityToken

java.lang.Object
  extended by org.limewire.security.AbstractSecurityToken
All Implemented Interfaces:
SecurityToken
Direct Known Subclasses:
AddressSecurityToken, DefaultMessageID.MessageSecurityToken, OOBSecurityToken

public abstract class AbstractSecurityToken
extends Object
implements SecurityToken

Implements a security token that can write itself to an output stream and queries for its validity.

Subclasses must implement getFromMAC(byte[], org.limewire.security.SecurityToken.TokenData). getFromMAC returns the payload of the security token as it will appear on the network.

See message authentication code, MAC, for more information.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.limewire.security.SecurityToken
SecurityToken.AddressSecurityTokenProvider, SecurityToken.TokenData, SecurityToken.TokenProvider
 
Constructor Summary
protected AbstractSecurityToken(byte[] network, MACCalculatorRepositoryManager mgr)
           
protected AbstractSecurityToken(SecurityToken.TokenData data, MACCalculatorRepositoryManager mgr)
           
 
Method Summary
 boolean equals(Object obj)
          Should not be used if it is possible to call isFor(org.limewire.security.SecurityToken.TokenData) which takes all possible MACCalculatorRepositories into account.
 byte[] getBytes()
          Returns the SecurityToken as byte array.
protected abstract  byte[] getFromMAC(byte[] MAC, SecurityToken.TokenData data)
           
 int hashCode()
           
 boolean isFor(SecurityToken.TokenData data)
          Validates that a SecurityToken was generated for the given TokenData.
protected  boolean isValidBytes(byte[] network)
          Determines if the given data bytes are valid.
protected  boolean isValidTokenData(SecurityToken.TokenData data)
          Determines if the given TokenData is valid for this SecurityToken.
 void write(OutputStream os)
          Writes the SecurityToken to the output stream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSecurityToken

protected AbstractSecurityToken(SecurityToken.TokenData data,
                                MACCalculatorRepositoryManager mgr)

AbstractSecurityToken

protected AbstractSecurityToken(byte[] network,
                                MACCalculatorRepositoryManager mgr)
                         throws InvalidSecurityTokenException
Throws:
InvalidSecurityTokenException
Method Detail

isFor

public final boolean isFor(SecurityToken.TokenData data)
Description copied from interface: SecurityToken
Validates that a SecurityToken was generated for the given TokenData.

Specified by:
isFor in interface SecurityToken

isValidTokenData

protected boolean isValidTokenData(SecurityToken.TokenData data)
Determines if the given TokenData is valid for this SecurityToken. By default, all TokenDatas are valid.


write

public final void write(OutputStream os)
                 throws IOException
Description copied from interface: SecurityToken
Writes the SecurityToken to the output stream.

Specified by:
write in interface SecurityToken
Throws:
IOException

getBytes

public final byte[] getBytes()
Description copied from interface: SecurityToken
Returns the SecurityToken as byte array.

Specified by:
getBytes in interface SecurityToken

getFromMAC

protected abstract byte[] getFromMAC(byte[] MAC,
                                     SecurityToken.TokenData data)
Parameters:
MAC - the calculated cryptographic MAC
data - the TokenData this security token is created from.
Returns:
the payload of this security token as it will appear on the network

isValidBytes

protected boolean isValidBytes(byte[] network)
Determines if the given data bytes are valid. By default, all non-null and non-empty bytes are valid.


equals

public boolean equals(Object obj)
Should not be used if it is possible to call isFor(org.limewire.security.SecurityToken.TokenData) which takes all possible MACCalculatorRepositories into account.

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

LimeWire Consolidated API

Copyright © 2009. All Rights Reserved.