Class IpExtractor
- java.lang.Object
-
- org.pac4j.http.credentials.extractor.IpExtractor
-
- All Implemented Interfaces:
CredentialsExtractor<TokenCredentials>
public class IpExtractor extends Object implements CredentialsExtractor<TokenCredentials>
To extract a remote IP address. Search for headers as defined in an array. The first match will be returned as specified forenhanced foriteration over arrays. By default, if no proxy ip is setted (setProxyIp(String)), only request from proxy IP will be accepted.- Since:
- 1.8.0
- Author:
- Jerome Leleu, Guilherme I F L Weizenmann
-
-
Constructor Summary
Constructors Constructor Description IpExtractor()IpExtractor(String... alternateIpHeaders)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<TokenCredentials>extract(WebContext context)ListgetAlternateIpHeaders()StringgetProxyIp()voidsetAlternateIpHeaders(String... alternateIpHeaders)voidsetProxyIp(String proxyIp)StringtoString()
-
-
-
Constructor Detail
-
IpExtractor
public IpExtractor()
-
IpExtractor
public IpExtractor(String... alternateIpHeaders)
-
-
Method Detail
-
extract
public Optional<TokenCredentials> extract(WebContext context)
- Specified by:
extractin interfaceCredentialsExtractor<TokenCredentials>
-
getProxyIp
public String getProxyIp()
- Returns:
- The verified proxy IP
- Since:
- 2.1.0
-
setProxyIp
public void setProxyIp(String proxyIp)
- Parameters:
proxyIp- Set the IP to verify the proxy request source. Settingnullor""(empty string) disabled the proxy IP check.- Since:
- 2.1.0
-
getAlternateIpHeaders
public List getAlternateIpHeaders()
- Returns:
- Defined headers to search for IP as
Collections.unmodifiableList(List) - Since:
- 2.1.0
-
setAlternateIpHeaders
public void setAlternateIpHeaders(String... alternateIpHeaders)
- Parameters:
alternateIpHeaders- Sets alternate headers to search for IP. The first match will be returned as specified forenhanced foriteration over arrays.- Since:
- 2.1.0
-
-