Example usage for org.springframework.security.web.util.matcher IpAddressMatcher matches

List of usage examples for org.springframework.security.web.util.matcher IpAddressMatcher matches

Introduction

In this page you can find the example usage for org.springframework.security.web.util.matcher IpAddressMatcher matches.

Prototype

public boolean matches(String address) 

Source Link

Usage

From source file:org.duracloud.account.security.auth.AuthProvider.java

/**
 * Determines if a given IP address is in the given IP range.
 *
 * @param ipAddress single IP address//from  w ww.j  a v  a 2s .  com
 * @param range IP address range using CIDR notation
 * @return true if the address is in the range, false otherwise
 */
protected boolean ipInRange(String ipAddress, String range) {
    IpAddressMatcher addressMatcher = new IpAddressMatcher(range);
    return addressMatcher.matches(ipAddress);
}

From source file:org.wikimedia.analytics.refinery.core.IpUtil.java

/**
 * Checks whether the given IP address matches any of the trusted proxies
 * <p>/*from www .j  a va 2 s .  c o  m*/
 * Assumes that the input IP address is already trimmed and validated
 * @param ip IP address
 * @return Boolean {@code true}, if the given ip address matches any of the
 * trustedProxies. {@code false} otherwise.
 */
private boolean isTrustedProxy(String ip) {
    boolean isTrusted = false;

    for (IpAddressMatcher ipAddressMatcher : trustedProxiesCache) {
        if (ipAddressMatcher.matches(ip)) {
            // The given ip matches one of the proxies in our list
            isTrusted = true;
            break;
        }
    }
    return isTrusted;
}

From source file:org.wikimedia.analytics.refinery.core.IpUtil.java

/**
 * Does the given IP address belong to a Wikimedia Labs hosted instance?
 * @param ip IP address/*from w  ww .  j ava 2  s .  c o m*/
 * @return Boolean {@code true} when ip matches Labs subnet, {@code false}
 * otherwise.
 */
private boolean isLabsHost(String ip) {
    boolean isLabs = false;

    for (IpAddressMatcher subnet : labsSubnetsCache) {
        if (subnet.matches(ip)) {
            isLabs = true;
            break;
        }
    }
    return isLabs;
}