// Path: core/src/main/java/org/juiser/model/User.java
// public interface User {
// 
//     /**
//      * Returns {@code true} if the user has been authenticated (proven their identity) or {@code false} if the user
//      * is considered anonymous.
//      *
//      * @return {@code true} if the user has been authenticated (proven their identity) or {@code false} if the user
//      * is considered anonymous.
//      */
//     boolean isAuthenticated();
// 
//     /**
//      * Returns {@code true} if the user identity is unknown, {@code false} if the user is authenticated.
//      *
//      * @return {@code true} if the user identity is unknown, {@code false} if the user is authenticated.
//      */
//     boolean isAnonymous();
// 
//     String getHref();
// 
//     String getId();
// 
//     String getName(); //full name
// 
//     String getGivenName(); //aka 'first name' in Western cultures
// 
//     String getFamilyName(); //aka surname
// 
//     String getMiddleName();
// 
//     String getNickname(); //aka 'Mike' if givenName is 'Michael'
// 
//     String getUsername(); //OIDC 'preferred_username'
// 
//     URL getProfile();
// 
//     URL getPicture();
// 
//     URL getWebsite();
// 
//     String getEmail();
// 
//     boolean isEmailVerified();
// 
//     String getGender();
// 
//     LocalDate getBirthdate();
// 
//     TimeZone getZoneInfo();
// 
//     Locale getLocale();
// 
//     Phone getPhone();
// 
//     String getPhoneNumber();
// 
//     boolean isPhoneNumberVerified();
// 
//     ZonedDateTime getCreatedAt();
// 
//     ZonedDateTime getUpdatedAt();
// }


import java.util.LinkedHashSet;
import java.util.function.Function;
import io.jsonwebtoken.lang.Assert;
import io.jsonwebtoken.lang.Collections;
import io.jsonwebtoken.lang.Strings;
import org.juiser.model.User;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collection;
/*
 * Copyright 2017 Les Hazlewood and the respective Juiser contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.juiser.servlet;



/**
 * @since 1.0.0
 */
public class ForwardedUserFilter implements Filter {

    private final String headerName;
// Path: core/src/main/java/org/juiser/model/User.java
// public interface User {
// 
//     /**
//      * Returns {@code true} if the user has been authenticated (proven their identity) or {@code false} if the user
//      * is considered anonymous.
//      *
//      * @return {@code true} if the user has been authenticated (proven their identity) or {@code false} if the user
//      * is considered anonymous.
//      */
//     boolean isAuthenticated();
// 
//     /**
//      * Returns {@code true} if the user identity is unknown, {@code false} if the user is authenticated.
//      *
//      * @return {@code true} if the user identity is unknown, {@code false} if the user is authenticated.
//      */
//     boolean isAnonymous();
// 
//     String getHref();
// 
//     String getId();
// 
//     String getName(); //full name
// 
//     String getGivenName(); //aka 'first name' in Western cultures
// 
//     String getFamilyName(); //aka surname
// 
//     String getMiddleName();
// 
//     String getNickname(); //aka 'Mike' if givenName is 'Michael'
// 
//     String getUsername(); //OIDC 'preferred_username'
// 
//     URL getProfile();
// 
//     URL getPicture();
// 
//     URL getWebsite();
// 
//     String getEmail();
// 
//     boolean isEmailVerified();
// 
//     String getGender();
// 
//     LocalDate getBirthdate();
// 
//     TimeZone getZoneInfo();
// 
//     Locale getLocale();
// 
//     Phone getPhone();
// 
//     String getPhoneNumber();
// 
//     boolean isPhoneNumberVerified();
// 
//     ZonedDateTime getCreatedAt();
// 
//     ZonedDateTime getUpdatedAt();
// }


// Path: servlet/src/main/java/org/juiser/servlet/ForwardedUserFilter.java
import java.util.LinkedHashSet;
import java.util.function.Function;
import io.jsonwebtoken.lang.Assert;
import io.jsonwebtoken.lang.Collections;
import io.jsonwebtoken.lang.Strings;
import org.juiser.model.User;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collection;

/*
 * Copyright 2017 Les Hazlewood and the respective Juiser contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.juiser.servlet;



/**
 * @since 1.0.0
 */
public class ForwardedUserFilter implements Filter {

    private final String headerName;
    private final Function<HttpServletRequest, User> userFactory;