class IpRegexpAuthenticator extends AbstractRegexpAuthenticator implements Authenticator {

    /**
     * <p>Constructor for IpRegexpAuthenticator.</p>
     */
    public IpRegexpAuthenticator() { }

    /**
     * <p>Constructor for IpRegexpAuthenticator.</p>
     *
     * @param regexpPattern a {@link String} object
     */
    public IpRegexpAuthenticator(final String regexpPattern) {
        setRegexpPattern(regexpPattern);
    }

    /** {@inheritDoc} */
    @Override
    protected void internalInit(final boolean forceReinit) {
        CommonHelper.assertNotNull("pattern", pattern);
        setProfileDefinitionIfUndefined(new CommonProfileDefinition(x -> new IpProfile()));
    }

    /** {@inheritDoc} */
    @Override
    public Optional<Credentials> validate(final CallContext ctx, final Credentials credentials) {<FILL_FUNCTION_BODY>}
}

        init();

        val ip = ((TokenCredentials) credentials).getToken();

        if (!this.pattern.matcher(ip).matches()) {
            throw new CredentialsException("Unauthorized IP address: " + ip);
        }

        UserProfile profile = (IpProfile) getProfileDefinition().newProfile();
        profile.setId(ip);
        logger.debug("profile: {}", profile);

        credentials.setUserProfile(profile);

        return Optional.of(credentials);
    
<methods>public non-sealed void <init>() ,public void setRegexpPattern(java.lang.String) <variables>protected final org.slf4j.Logger logger,protected java.util.regex.Pattern pattern,protected java.lang.String regexpPattern