anon.client
Class TrustModel

java.lang.Object
  extended by java.util.Observable
      extended by anon.client.BasicTrustModel
          extended by anon.client.TrustModel
All Implemented Interfaces:
ITrustModel, IXMLEncodable

public class TrustModel
extends BasicTrustModel
implements IXMLEncodable

This is the general trust model for JAP.

Author:
Rolf Wendolsky

Nested Class Summary
static class TrustModel.AnonLevelAttribute
           
static class TrustModel.ContextAttribute
           
static class TrustModel.DataRetentionAttribute
           
static class TrustModel.DelayAttribute
           
static class TrustModel.InnerObservable
           
static class TrustModel.InternationalAttribute
           
static class TrustModel.NumberOfMixesAttribute
           
static class TrustModel.OperatorBlacklistAttribute
           
static class TrustModel.PremiumAttribute
           
static class TrustModel.SocksAttribute
           
static class TrustModel.SpeedAttribute
           
static class TrustModel.TrustAttribute
           
static class TrustModel.UserDefinedAttribute
           
 
Field Summary
private static TrustModel CONTEXT_MODEL_ALL
           
private static TrustModel CONTEXT_MODEL_BUSINESS
           
private static TrustModel CONTEXT_MODEL_FREE
           
private static TrustModel CONTEXT_MODEL_PREMIUM
           
private static TrustModel CONTEXT_MODEL_PREMIUM_PRIVATE
           
static int FIRST_UNRESERVED_MODEL_ID
          Unreserved IDs may be used by controller classes to define more models.
private  boolean m_bEditable
           
private  long m_id
           
private  java.lang.String m_strName
           
private  java.util.Hashtable m_trustAttributes
           
private static TrustModel ms_currentTrustModel
           
private static java.lang.String ms_strContext
           
private static TrustModel.InnerObservable ms_trustModelObservable
           
private static java.util.Vector ms_trustModels
           
private static java.lang.String MSG_ALL_SERVICES
           
static java.lang.String MSG_BLACKLISTED
           
private static java.lang.String MSG_CASCADES_FILTER
           
private static java.lang.String MSG_EXCEPTION_BLACKLISTED
           
private static java.lang.String MSG_EXCEPTION_DATA_RETENTION
           
private static java.lang.String MSG_EXCEPTION_EXPIRED_CERT
           
static java.lang.String MSG_EXCEPTION_FREE_CASCADE
           
private static java.lang.String MSG_EXCEPTION_INTERNATIONAL
           
private static java.lang.String MSG_EXCEPTION_NO_SOCKS
           
private static java.lang.String MSG_EXCEPTION_NOT_ENOUGH_ANON
           
static java.lang.String MSG_EXCEPTION_NOT_ENOUGH_MIXES
           
private static java.lang.String MSG_EXCEPTION_NOT_ENOUGH_SPEED
           
private static java.lang.String MSG_EXCEPTION_NOT_INTERNATIONAL
           
private static java.lang.String MSG_EXCEPTION_NOT_USER_DEFINED
           
private static java.lang.String MSG_EXCEPTION_PAY_CASCADE
           
private static java.lang.String MSG_EXCEPTION_RESPONSE_TIME_TOO_HIGH
           
private static java.lang.String MSG_EXCEPTION_TOO_FEW_COUNTRIES
           
private static java.lang.String MSG_EXCEPTION_WRONG_SERVICE_CONTEXT
           
static java.lang.String MSG_PI_UNAVAILABLE
           
private static java.lang.String MSG_SERVICES_BUSINESS
           
private static java.lang.String MSG_SERVICES_PREMIUM_PRIVATE
           
private static java.lang.String MSG_SERVICES_USER_DEFINED
           
private static java.lang.String MSG_SERVICES_WITH_COSTS
           
static java.lang.String MSG_SERVICES_WITHOUT_COSTS
           
static java.lang.Integer NOTIFY_TRUST_MODEL_ADDED
           
static java.lang.Integer NOTIFY_TRUST_MODEL_CHANGED
           
static java.lang.Integer NOTIFY_TRUST_MODEL_REMOVED
           
static int TRUST_ALWAYS
          Always trust the cascade, regardless of the attribute
static int TRUST_IF_AT_LEAST
          Only trust the cascade if the attribute is greater than a specified value
static int TRUST_IF_AT_MOST
          Only trust the cascade if the attribute is lesser than a specified value
static int TRUST_IF_NOT_IN_LIST
          Only trust the cascade if the attribute value is not within the specified list
static int TRUST_IF_NOT_TRUE
          Only trust the cascade if the attribute is NOT true
static int TRUST_IF_TRUE
          Only trust the cascade if the attribute is true
static long TRUST_MODEL_ALL
           
private static TrustModel TRUST_MODEL_CUSTOM_FILTER
           
private static TrustModel TRUST_MODEL_DEFAULT
           
private static TrustModel TRUST_MODEL_PREMIUM
           
static TrustModel TRUST_MODEL_USER_DEFINED
           
static int TRUST_RESERVED
          Reserved for future use
private static java.lang.String XML_ATTR_CURRENT_TRUST_MODEL
           
private static java.lang.String XML_ATTR_NAME
           
static java.lang.String XML_ELEMENT_CONTAINER_NAME
           
static java.lang.String XML_ELEMENT_NAME
           
 
Fields inherited from interface anon.util.IXMLEncodable
FIELD_XML_ELEMENT_CONTAINER_NAME, FIELD_XML_ELEMENT_NAME, XML_ATTR_ID, XML_ATTR_LANGUAGE, XML_ATTR_VERSION
 
Constructor Summary
  TrustModel(org.w3c.dom.Element a_trustModelElement)
          Creates a TrustModel object from an XML element
  TrustModel(java.lang.String a_strName, long a_id)
          Creates a new TrustModel object with the specified name
private TrustModel(java.lang.String a_strName, long a_id, boolean b_allowReservedID)
           
  TrustModel(TrustModel a_trustModel)
          Creates a TrustModel object from another TrustModel object
 
Method Summary
static void addModelObserver(java.util.Observer a_observer)
           
static boolean addTrustModel(TrustModel a_trustModel)
           
 void checkTrust(MixCascade a_cascade)
           
 void copyFrom(TrustModel a_trustModel)
           
static void deleteModelObserver(java.util.Observer a_observer)
           
 boolean equals(java.lang.Object a_trustModel)
          Compares two TrustModel objects
static void forceFreeTrustModel()
           
static void fromXmlElement(org.w3c.dom.Element a_container)
           
 TrustModel.TrustAttribute getAttribute(java.lang.Class a_attr)
           
static java.lang.String getContext()
           
static TrustModel getCurrentTrustModel()
           
static TrustModel getCustomFilter()
           
 long getId()
           
 java.lang.String getName()
          Returns the localized name of the TrustModel
static java.util.Observable getObservable()
           
static TrustModel getTrustModelDefault()
           
static TrustModel getTrustModelPremium()
           
static java.util.Vector getTrustModels()
           
static TrustModel getTrustModelUserDefined()
           
 int hashCode()
           
 boolean hasTrustedCascades()
          Checks if the current trust model has any trusted cascades at all
 boolean isAdded()
           
static boolean isBlacklisted(MixCascade a_cascade)
           
 boolean isEditable()
           
static boolean isNoPaymentInstanceFound(MixCascade a_cascade)
           
 boolean isPaymentForced()
           
static TrustModel removeTrustModel(TrustModel a_trustModel)
           
static void restoreDefault()
           
 TrustModel.TrustAttribute setAttribute(java.lang.Class a_attr, int a_trustCondition)
           
private  TrustModel.TrustAttribute setAttribute(java.lang.Class a_attr, int a_trustCondition, boolean a_bIgnoreNoDataAvailable)
           
 TrustModel.TrustAttribute setAttribute(java.lang.Class a_attr, int a_trustCondition, int a_conditionValue)
           
private  TrustModel.TrustAttribute setAttribute(java.lang.Class a_attr, int a_trustCondition, int a_conditionValue, boolean a_bIgnoreNoDataAvailable)
           
private  TrustModel.TrustAttribute setAttribute(java.lang.Class a_attr, int a_trustCondition, java.lang.Object a_conditionValue, boolean a_bIgnoreNoDataAvailable)
           
 TrustModel.TrustAttribute setAttribute(java.lang.Class a_attr, int a_trustCondition, java.util.Vector a_conditionValue)
           
private  TrustModel.TrustAttribute setAttribute(TrustModel.TrustAttribute a_attr)
           
static void setCurrentTrustModel(long a_id)
           
static void setCurrentTrustModel(TrustModel a_trustModel)
           
 void setEditable(boolean a_bEditable)
           
 void setName(java.lang.String a_strName)
           
 java.lang.String toString()
           
 org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
          Return an element that can be appended to the document.
static org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc, java.lang.String a_xmlContainerName)
           
static boolean updateContext(java.lang.String a_context)
           
 
Methods inherited from class anon.client.BasicTrustModel
isTrusted, isTrusted
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NOTIFY_TRUST_MODEL_CHANGED

public static final java.lang.Integer NOTIFY_TRUST_MODEL_CHANGED

NOTIFY_TRUST_MODEL_ADDED

public static final java.lang.Integer NOTIFY_TRUST_MODEL_ADDED

NOTIFY_TRUST_MODEL_REMOVED

public static final java.lang.Integer NOTIFY_TRUST_MODEL_REMOVED

FIRST_UNRESERVED_MODEL_ID

public static final int FIRST_UNRESERVED_MODEL_ID
Unreserved IDs may be used by controller classes to define more models. IDs lower than FIRST_UNRESERVED_MODEL_ID may not be used.

See Also:
Constant Field Values

XML_ELEMENT_NAME

public static final java.lang.String XML_ELEMENT_NAME
See Also:
Constant Field Values

XML_ELEMENT_CONTAINER_NAME

public static final java.lang.String XML_ELEMENT_CONTAINER_NAME
See Also:
Constant Field Values

XML_ATTR_CURRENT_TRUST_MODEL

private static final java.lang.String XML_ATTR_CURRENT_TRUST_MODEL
See Also:
Constant Field Values

XML_ATTR_NAME

private static final java.lang.String XML_ATTR_NAME
See Also:
Constant Field Values

TRUST_MODEL_USER_DEFINED

public static final TrustModel TRUST_MODEL_USER_DEFINED

TRUST_MODEL_DEFAULT

private static TrustModel TRUST_MODEL_DEFAULT

TRUST_MODEL_PREMIUM

private static TrustModel TRUST_MODEL_PREMIUM

TRUST_MODEL_CUSTOM_FILTER

private static TrustModel TRUST_MODEL_CUSTOM_FILTER

TRUST_ALWAYS

public static final int TRUST_ALWAYS
Always trust the cascade, regardless of the attribute

See Also:
Constant Field Values

TRUST_IF_NOT_TRUE

public static final int TRUST_IF_NOT_TRUE
Only trust the cascade if the attribute is NOT true

See Also:
Constant Field Values

TRUST_IF_TRUE

public static final int TRUST_IF_TRUE
Only trust the cascade if the attribute is true

See Also:
Constant Field Values

TRUST_IF_AT_LEAST

public static final int TRUST_IF_AT_LEAST
Only trust the cascade if the attribute is greater than a specified value

See Also:
Constant Field Values

TRUST_IF_AT_MOST

public static final int TRUST_IF_AT_MOST
Only trust the cascade if the attribute is lesser than a specified value

See Also:
Constant Field Values

TRUST_IF_NOT_IN_LIST

public static final int TRUST_IF_NOT_IN_LIST
Only trust the cascade if the attribute value is not within the specified list

See Also:
Constant Field Values

TRUST_RESERVED

public static final int TRUST_RESERVED
Reserved for future use

See Also:
Constant Field Values

TRUST_MODEL_ALL

public static final long TRUST_MODEL_ALL
See Also:
Constant Field Values

MSG_SERVICES_WITH_COSTS

private static final java.lang.String MSG_SERVICES_WITH_COSTS

MSG_SERVICES_WITHOUT_COSTS

public static final java.lang.String MSG_SERVICES_WITHOUT_COSTS

MSG_SERVICES_USER_DEFINED

private static final java.lang.String MSG_SERVICES_USER_DEFINED

MSG_CASCADES_FILTER

private static final java.lang.String MSG_CASCADES_FILTER

MSG_ALL_SERVICES

private static final java.lang.String MSG_ALL_SERVICES

MSG_SERVICES_BUSINESS

private static final java.lang.String MSG_SERVICES_BUSINESS

MSG_SERVICES_PREMIUM_PRIVATE

private static final java.lang.String MSG_SERVICES_PREMIUM_PRIVATE

MSG_PI_UNAVAILABLE

public static final java.lang.String MSG_PI_UNAVAILABLE

MSG_BLACKLISTED

public static final java.lang.String MSG_BLACKLISTED

MSG_EXCEPTION_NO_SOCKS

private static final java.lang.String MSG_EXCEPTION_NO_SOCKS

MSG_EXCEPTION_DATA_RETENTION

private static final java.lang.String MSG_EXCEPTION_DATA_RETENTION

MSG_EXCEPTION_PAY_CASCADE

private static final java.lang.String MSG_EXCEPTION_PAY_CASCADE

MSG_EXCEPTION_FREE_CASCADE

public static final java.lang.String MSG_EXCEPTION_FREE_CASCADE

MSG_EXCEPTION_WRONG_SERVICE_CONTEXT

private static final java.lang.String MSG_EXCEPTION_WRONG_SERVICE_CONTEXT

MSG_EXCEPTION_NOT_ENOUGH_MIXES

public static final java.lang.String MSG_EXCEPTION_NOT_ENOUGH_MIXES

MSG_EXCEPTION_EXPIRED_CERT

private static final java.lang.String MSG_EXCEPTION_EXPIRED_CERT

MSG_EXCEPTION_NOT_USER_DEFINED

private static final java.lang.String MSG_EXCEPTION_NOT_USER_DEFINED

MSG_EXCEPTION_TOO_FEW_COUNTRIES

private static final java.lang.String MSG_EXCEPTION_TOO_FEW_COUNTRIES

MSG_EXCEPTION_NOT_INTERNATIONAL

private static final java.lang.String MSG_EXCEPTION_NOT_INTERNATIONAL

MSG_EXCEPTION_INTERNATIONAL

private static final java.lang.String MSG_EXCEPTION_INTERNATIONAL

MSG_EXCEPTION_NOT_ENOUGH_ANON

private static final java.lang.String MSG_EXCEPTION_NOT_ENOUGH_ANON

MSG_EXCEPTION_BLACKLISTED

private static final java.lang.String MSG_EXCEPTION_BLACKLISTED

MSG_EXCEPTION_NOT_ENOUGH_SPEED

private static final java.lang.String MSG_EXCEPTION_NOT_ENOUGH_SPEED

MSG_EXCEPTION_RESPONSE_TIME_TOO_HIGH

private static final java.lang.String MSG_EXCEPTION_RESPONSE_TIME_TOO_HIGH

ms_trustModels

private static java.util.Vector ms_trustModels

ms_currentTrustModel

private static TrustModel ms_currentTrustModel

ms_strContext

private static java.lang.String ms_strContext

ms_trustModelObservable

private static TrustModel.InnerObservable ms_trustModelObservable

CONTEXT_MODEL_PREMIUM

private static final TrustModel CONTEXT_MODEL_PREMIUM

CONTEXT_MODEL_PREMIUM_PRIVATE

private static final TrustModel CONTEXT_MODEL_PREMIUM_PRIVATE

CONTEXT_MODEL_BUSINESS

private static final TrustModel CONTEXT_MODEL_BUSINESS

CONTEXT_MODEL_FREE

private static final TrustModel CONTEXT_MODEL_FREE

CONTEXT_MODEL_ALL

private static final TrustModel CONTEXT_MODEL_ALL

m_trustAttributes

private java.util.Hashtable m_trustAttributes

m_strName

private java.lang.String m_strName

m_id

private long m_id

m_bEditable

private boolean m_bEditable
Constructor Detail

TrustModel

public TrustModel(java.lang.String a_strName,
                  long a_id)
Creates a new TrustModel object with the specified name

Parameters:
a_strName - The name of the TrustModel

TrustModel

private TrustModel(java.lang.String a_strName,
                   long a_id,
                   boolean b_allowReservedID)

TrustModel

public TrustModel(TrustModel a_trustModel)
Creates a TrustModel object from another TrustModel object

Parameters:
a_trustModel - The TrustModel object to copy

TrustModel

public TrustModel(org.w3c.dom.Element a_trustModelElement)
           throws XMLParseException
Creates a TrustModel object from an XML element

Parameters:
a_trustModelElement - The XML element which holds the TrustModel data
Throws:
XMLParseException
Method Detail

getContext

public static java.lang.String getContext()

updateContext

public static boolean updateContext(java.lang.String a_context)

copyFrom

public void copyFrom(TrustModel a_trustModel)

getObservable

public static java.util.Observable getObservable()

addModelObserver

public static void addModelObserver(java.util.Observer a_observer)

deleteModelObserver

public static void deleteModelObserver(java.util.Observer a_observer)

equals

public boolean equals(java.lang.Object a_trustModel)
Compares two TrustModel objects

Overrides:
equals in class java.lang.Object
Returns:
true if the id's of the two objects match, false otherwise

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

addTrustModel

public static boolean addTrustModel(TrustModel a_trustModel)

removeTrustModel

public static TrustModel removeTrustModel(TrustModel a_trustModel)

setAttribute

public TrustModel.TrustAttribute setAttribute(java.lang.Class a_attr,
                                              int a_trustCondition)

setAttribute

private TrustModel.TrustAttribute setAttribute(java.lang.Class a_attr,
                                               int a_trustCondition,
                                               boolean a_bIgnoreNoDataAvailable)

setAttribute

public TrustModel.TrustAttribute setAttribute(java.lang.Class a_attr,
                                              int a_trustCondition,
                                              int a_conditionValue)

setAttribute

private TrustModel.TrustAttribute setAttribute(java.lang.Class a_attr,
                                               int a_trustCondition,
                                               int a_conditionValue,
                                               boolean a_bIgnoreNoDataAvailable)

setAttribute

public TrustModel.TrustAttribute setAttribute(java.lang.Class a_attr,
                                              int a_trustCondition,
                                              java.util.Vector a_conditionValue)

setEditable

public void setEditable(boolean a_bEditable)

isEditable

public boolean isEditable()

setAttribute

private TrustModel.TrustAttribute setAttribute(java.lang.Class a_attr,
                                               int a_trustCondition,
                                               java.lang.Object a_conditionValue,
                                               boolean a_bIgnoreNoDataAvailable)

setAttribute

private TrustModel.TrustAttribute setAttribute(TrustModel.TrustAttribute a_attr)

getAttribute

public TrustModel.TrustAttribute getAttribute(java.lang.Class a_attr)

getTrustModels

public static java.util.Vector getTrustModels()

forceFreeTrustModel

public static void forceFreeTrustModel()

setCurrentTrustModel

public static void setCurrentTrustModel(long a_id)

setCurrentTrustModel

public static void setCurrentTrustModel(TrustModel a_trustModel)

getTrustModelUserDefined

public static TrustModel getTrustModelUserDefined()

getTrustModelPremium

public static TrustModel getTrustModelPremium()

getTrustModelDefault

public static TrustModel getTrustModelDefault()

getCurrentTrustModel

public static TrustModel getCurrentTrustModel()

getCustomFilter

public static TrustModel getCustomFilter()

fromXmlElement

public static void fromXmlElement(org.w3c.dom.Element a_container)

restoreDefault

public static void restoreDefault()

toXmlElement

public static org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc,
                                               java.lang.String a_xmlContainerName)

setName

public void setName(java.lang.String a_strName)
             throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

getName

public java.lang.String getName()
Returns the localized name of the TrustModel

Returns:
The localized name of the TrustModel

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getId

public long getId()

toXmlElement

public org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
Description copied from interface: IXMLEncodable
Return an element that can be appended to the document. This Method must not change the document in any way!

Specified by:
toXmlElement in interface IXMLEncodable
Parameters:
a_doc - a document
Returns:
the interface as xml element

isPaymentForced

public boolean isPaymentForced()

isAdded

public boolean isAdded()

hasTrustedCascades

public boolean hasTrustedCascades()
Checks if the current trust model has any trusted cascades at all

Returns:
true if the trust model has trusted cascades, false otherwise

isBlacklisted

public static boolean isBlacklisted(MixCascade a_cascade)

isNoPaymentInstanceFound

public static boolean isNoPaymentInstanceFound(MixCascade a_cascade)

checkTrust

public void checkTrust(MixCascade a_cascade)
                throws TrustException,
                       java.security.SignatureException
Specified by:
checkTrust in interface ITrustModel
Overrides:
checkTrust in class BasicTrustModel
Throws:
TrustException
java.security.SignatureException