LimeWire Consolidated API

org.limewire.security
Class AddressSecurityToken

java.lang.Object
  extended by org.limewire.security.AbstractSecurityToken
      extended by org.limewire.security.AddressSecurityToken
All Implemented Interfaces:
SecurityToken

public final class AddressSecurityToken
extends AbstractSecurityToken

A token that embeds an IP address and port, allowing one side to generate a token for a specific IP address/port pair that cannot be easily guessed.


Nested Class Summary
static class AddressSecurityToken.AddressTokenData
          Converts the IP address and port into an encrypted byte[].
 
Nested classes/interfaces inherited from interface org.limewire.security.SecurityToken
SecurityToken.AddressSecurityTokenProvider, SecurityToken.TokenData, SecurityToken.TokenProvider
 
Field Summary
static int MAX_QK_SIZE_IN_BYTES
          As detailed by the GUESS specification.
static int MIN_QK_SIZE_IN_BYTES
          As detailed by the GUESS specification ( Gnutella UDP Extension for Scalable Searches ).
 
Constructor Summary
AddressSecurityToken(AddressSecurityToken.AddressTokenData data, MACCalculatorRepositoryManager mgr)
           
AddressSecurityToken(byte[] key, MACCalculatorRepositoryManager mgr)
           
AddressSecurityToken(InetAddress ip, int port, MACCalculatorRepositoryManager mgr)
          Generates an AddressSecurityToken for a given IP:Port combo.
AddressSecurityToken(SocketAddress address, MACCalculatorRepositoryManager mgr)
          Generates a AddressSecurityToken for a given SocketAddress.
 
Method Summary
protected  byte[] getFromMAC(byte[] key, SecurityToken.TokenData ignored)
           
 int hashCode()
           
 boolean isFor(InetAddress ip, int port)
           
 boolean isFor(SocketAddress address)
           
protected  boolean isValidBytes(byte[] key)
          Determines if the given data bytes are valid.
static boolean isValidSecurityTokenBytes(byte[] key)
          Determines if the bytes are valid for a key.
 String toString()
          Returns a String with the AddressSecurityToken represented in hexadecimal.
 
Methods inherited from class org.limewire.security.AbstractSecurityToken
equals, getBytes, isFor, isValidTokenData, write
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_QK_SIZE_IN_BYTES

public static final int MIN_QK_SIZE_IN_BYTES
As detailed by the GUESS specification ( Gnutella UDP Extension for Scalable Searches ).

See Also:
Constant Field Values

MAX_QK_SIZE_IN_BYTES

public static final int MAX_QK_SIZE_IN_BYTES
As detailed by the GUESS specification.

See Also:
Constant Field Values
Constructor Detail

AddressSecurityToken

public AddressSecurityToken(SocketAddress address,
                            MACCalculatorRepositoryManager mgr)
Generates a AddressSecurityToken for a given SocketAddress. For a given SocketAddress, using a different SecretKey and/or SecretPad will result in a different AddressSecurityToken.


AddressSecurityToken

public AddressSecurityToken(InetAddress ip,
                            int port,
                            MACCalculatorRepositoryManager mgr)
Generates an AddressSecurityToken for a given IP:Port combo. For a given IP:Port combo, using a different SecretKey and/or SecretPad will result in a different AddressSecurityToken.

Parameters:
ip - the IP address of the other node
port - the port of the other node

AddressSecurityToken

public AddressSecurityToken(AddressSecurityToken.AddressTokenData data,
                            MACCalculatorRepositoryManager mgr)

AddressSecurityToken

public AddressSecurityToken(byte[] key,
                            MACCalculatorRepositoryManager mgr)
                     throws InvalidSecurityTokenException
Throws:
InvalidSecurityTokenException
Method Detail

getFromMAC

protected byte[] getFromMAC(byte[] key,
                            SecurityToken.TokenData ignored)
Specified by:
getFromMAC in class AbstractSecurityToken
Parameters:
key - the calculated cryptographic MAC
ignored - the TokenData this security token is created from.
Returns:
the payload of this security token as it will appear on the network

isFor

public boolean isFor(SocketAddress address)

isFor

public boolean isFor(InetAddress ip,
                     int port)

hashCode

public int hashCode()
Overrides:
hashCode in class AbstractSecurityToken

toString

public String toString()
Returns a String with the AddressSecurityToken represented in hexadecimal.

Overrides:
toString in class Object

isValidSecurityTokenBytes

public static boolean isValidSecurityTokenBytes(byte[] key)
Determines if the bytes are valid for a key.


isValidBytes

protected boolean isValidBytes(byte[] key)
Description copied from class: AbstractSecurityToken
Determines if the given data bytes are valid. By default, all non-null and non-empty bytes are valid.

Overrides:
isValidBytes in class AbstractSecurityToken

LimeWire Consolidated API

Copyright © 2009. All Rights Reserved.