Class IpExtractor
java.lang.Object
org.pac4j.http.credentials.extractor.IpExtractor
- All Implemented Interfaces:
org.pac4j.core.credentials.extractor.CredentialsExtractor
public class IpExtractor
extends Object
implements org.pac4j.core.credentials.extractor.CredentialsExtractor
To extract a remote IP address.
Search for headers as defined in an array.
The first match will be returned as specified for
enhanced for
iteration 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
-
Method Summary
Modifier and TypeMethodDescriptionOptional<org.pac4j.core.credentials.Credentials>
extract
(org.pac4j.core.context.WebContext context, org.pac4j.core.context.session.SessionStore sessionStore) void
setAlternateIpHeaders
(String... alternateIpHeaders) void
setProxyIp
(String proxyIp) toString()
-
Constructor Details
-
IpExtractor
public IpExtractor() -
IpExtractor
-
-
Method Details
-
extract
public Optional<org.pac4j.core.credentials.Credentials> extract(org.pac4j.core.context.WebContext context, org.pac4j.core.context.session.SessionStore sessionStore) - Specified by:
extract
in interfaceorg.pac4j.core.credentials.extractor.CredentialsExtractor
-
getProxyIp
- Returns:
- The verified proxy IP
- Since:
- 2.1.0
-
setProxyIp
- Parameters:
proxyIp
- Set the IP to verify the proxy request source. Settingnull
or""
(empty string) disabled the proxy IP check.- Since:
- 2.1.0
-
getAlternateIpHeaders
- Returns:
- Defined headers to search for IP as
Collections.unmodifiableList(List)
- Since:
- 2.1.0
-
setAlternateIpHeaders
- Parameters:
alternateIpHeaders
- Sets alternate headers to search for IP. The first match will be returned as specified forenhanced for
iteration over arrays.- Since:
- 2.1.0
-
toString
-