com.atlassian.crowd.manager.proxy
Class TrustedProxyManagerImpl

java.lang.Object
  extended by com.atlassian.crowd.manager.proxy.TrustedProxyManagerImpl
All Implemented Interfaces:
TrustedProxyManager

public class TrustedProxyManagerImpl
extends java.lang.Object
implements TrustedProxyManager

Handles the list of proxy servers whose X-Forwarded-For headers we trust. Deals with persisting and querying the list.


Field Summary
protected static java.lang.String REQUESTED_PROXIES_CACHE_KEY
           
protected static java.lang.String TRUSTED_PROXIES_CACHE_KEY
           
protected static java.lang.String TRUSTED_PROXIES_STRING_CACHE_KEY
           
 
Constructor Summary
TrustedProxyManagerImpl()
           
 
Method Summary
 boolean add(java.lang.String remoteAddress)
          Adds to the list of servers we trust.
 java.util.List<java.lang.String> getList()
          Returns the list of trusted proxy servers, or an empty list if there are none.
protected  java.util.List<java.lang.String> getListFromCache()
          Loads the list from the cache.
protected  java.lang.String getProperty()
          Loads the server property that contains the list of trusted proxies.
protected  java.util.List<RemoteAddress> getRemoteAddressFromCache()
          Loads the list from the cache.
protected  java.util.Map<java.lang.String,java.lang.Boolean> getRequestedProxiesMapFromCache()
          Loads a map of requested proxies from the cache.
 boolean isTrusted(java.lang.String remoteAddress)
          Returns true if the proxy server is trusted, false otherwise.
 void remove(java.lang.String remoteAddress)
          Removes from the list of trusted servers.
protected  boolean saveList(java.util.List<java.lang.String> trustedProxies)
          Saves the updated list and reloads it.
 void setCacheManager(CacheManager cacheManager)
           
protected  boolean setProperty(java.lang.String value)
          Sets the server property with the specified list of trusted proxies.
 void setPropertyManager(PropertyManager propertyManager)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRUSTED_PROXIES_STRING_CACHE_KEY

protected static final java.lang.String TRUSTED_PROXIES_STRING_CACHE_KEY

TRUSTED_PROXIES_CACHE_KEY

protected static final java.lang.String TRUSTED_PROXIES_CACHE_KEY

REQUESTED_PROXIES_CACHE_KEY

protected static final java.lang.String REQUESTED_PROXIES_CACHE_KEY
Constructor Detail

TrustedProxyManagerImpl

public TrustedProxyManagerImpl()
Method Detail

isTrusted

public boolean isTrusted(java.lang.String remoteAddress)
Returns true if the proxy server is trusted, false otherwise.

Specified by:
isTrusted in interface TrustedProxyManager
Parameters:
remoteAddress -
Returns:

getList

public java.util.List<java.lang.String> getList()
Returns the list of trusted proxy servers, or an empty list if there are none.

Specified by:
getList in interface TrustedProxyManager
Returns:

add

public boolean add(java.lang.String remoteAddress)
Adds to the list of servers we trust. Pass an IP address in decimal dot format (eg. 192.168.3.2) Allows IP addresses with subnets as well (eg. 192.168.3.0/24)

Specified by:
add in interface TrustedProxyManager
Parameters:
remoteAddress -
Returns:
true if the addition was successful, false otherwise

remove

public void remove(java.lang.String remoteAddress)
Removes from the list of trusted servers.

Specified by:
remove in interface TrustedProxyManager
Parameters:
remoteAddress -

getProperty

protected java.lang.String getProperty()
Loads the server property that contains the list of trusted proxies. If there are none, returns null.

Returns:

setProperty

protected boolean setProperty(java.lang.String value)
Sets the server property with the specified list of trusted proxies.

Parameters:
value - list of trusted proxies as a comma delimited string
Returns:
true if property successfully set; false otherwise.

getRequestedProxiesMapFromCache

protected java.util.Map<java.lang.String,java.lang.Boolean> getRequestedProxiesMapFromCache()
Loads a map of requested proxies from the cache. If not in cache, returns an empty map.

Returns:

getListFromCache

protected java.util.List<java.lang.String> getListFromCache()
Loads the list from the cache. If not in the cache, goes to the PropertyManager and loads from there.

Returns:
A list of String of trusted proxies. Empty list if there are no trusted proxies.

getRemoteAddressFromCache

protected java.util.List<RemoteAddress> getRemoteAddressFromCache()
Loads the list from the cache. If not in the cache, goes to the PropertyManager and loads from there.

Returns:
A list of RemoteAddress of trusted proxies.

saveList

protected boolean saveList(java.util.List<java.lang.String> trustedProxies)
Saves the updated list and reloads it. Clears all caches.

Parameters:
trustedProxies -

setPropertyManager

public void setPropertyManager(PropertyManager propertyManager)

setCacheManager

public void setCacheManager(CacheManager cacheManager)


Copyright © 2010 Atlassian. All Rights Reserved.