com.atlassian.crowd.util
Class RemoteAddressHelper

java.lang.Object
  extended by com.atlassian.crowd.util.RemoteAddressHelper

public class RemoteAddressHelper
extends java.lang.Object


Constructor Summary
RemoteAddressHelper()
           
 
Method Summary
static byte[] getAddressInBytes(java.lang.String address)
          Converts String representation of valid IP addresses into a byte array.
static boolean isAddressAllowed(RemoteAddress allowedAddress, RemoteAddress requestAddress)
          Compares the request address (hostname or IP address) with the specified allowed address (hostname or IP address) to determine if the request address matches the allowed address.
static boolean isValidIPNotation(java.lang.String address)
          Determines if the provided string is a valid IP address
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteAddressHelper

public RemoteAddressHelper()
Method Detail

isAddressAllowed

public static boolean isAddressAllowed(RemoteAddress allowedAddress,
                                       RemoteAddress requestAddress)
Compares the request address (hostname or IP address) with the specified allowed address (hostname or IP address) to determine if the request address matches the allowed address. The allowed address can have a CIDR mask specified, if the request address falls within the subnet specified by the CIDR mask, it will be determined to "match" the allowed address

Parameters:
allowedAddress - a hostname or IP address that is allowed
requestAddress - the address to check against the specified allowedAddress to determine if it shall be allowed or not
Returns:
true iff the requestAddress matches the allowedAddress

getAddressInBytes

public static byte[] getAddressInBytes(java.lang.String address)
Converts String representation of valid IP addresses into a byte array. If address is not a valid IP address (eg. a hostname), no conversion will be made.

Parameters:
address - hostname or IP address
Returns:
a byte array representing the IP address if a valid IPv4 or IPv6 address has been given. null if a hostname is provided, or an invalid IP address format is provided

isValidIPNotation

public static boolean isValidIPNotation(java.lang.String address)
Determines if the provided string is a valid IP address

Parameters:
address - IP address
Returns:
true iff address is a valid IPv4 or IPv6 address


Copyright © 2011 Atlassian. All Rights Reserved.