| | |
| | | package com.gitblit.servlet;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.UnsupportedEncodingException;
|
| | | import java.net.URLDecoder;
|
| | | import java.security.Principal;
|
| | | import java.util.Enumeration;
|
| | | import java.util.HashMap;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.servlet.Filter;
|
| | | import javax.servlet.FilterChain;
|
| | | import javax.servlet.FilterConfig;
|
| | | import javax.servlet.ServletException;
|
| | |
| | | import org.slf4j.LoggerFactory;
|
| | |
|
| | | import com.gitblit.Constants;
|
| | | import com.gitblit.dagger.DaggerFilter;
|
| | | import com.gitblit.manager.IAuthenticationManager;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.gitblit.utils.DeepCopier;
|
| | | import com.gitblit.utils.StringUtils;
|
| | |
|
| | | import dagger.ObjectGraph;
|
| | |
|
| | | /**
|
| | | * The AuthenticationFilter is a servlet filter that preprocesses requests that
|
| | |
| | | * @author James Moger
|
| | | *
|
| | | */
|
| | | public abstract class AuthenticationFilter implements Filter {
|
| | | public abstract class AuthenticationFilter extends DaggerFilter {
|
| | |
|
| | | protected static final String CHALLENGE = "Basic realm=\"" + Constants.NAME + "\"";
|
| | |
|
| | |
| | |
|
| | | protected transient Logger logger = LoggerFactory.getLogger(getClass());
|
| | |
|
| | | protected final IAuthenticationManager authenticationManager;
|
| | | protected IAuthenticationManager authenticationManager;
|
| | |
|
| | | protected AuthenticationFilter(IAuthenticationManager authenticationManager) {
|
| | | this.authenticationManager = authenticationManager;
|
| | | @Override
|
| | | protected void inject(ObjectGraph dagger, FilterConfig filterConfig) {
|
| | | this.authenticationManager = dagger.get(IAuthenticationManager.class);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | url = url.substring(1);
|
| | | }
|
| | | String fullUrl = url + (StringUtils.isEmpty(params) ? "" : ("?" + params));
|
| | | try {
|
| | | fullUrl = URLDecoder.decode(fullUrl, "UTF-8");
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | logger.warn("UTF-8 decoding of URL failed: "+fullUrl, e);
|
| | | e.printStackTrace();
|
| | | }
|
| | | return fullUrl;
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
|
| | | */
|
| | | @Override
|
| | | public void init(final FilterConfig config) throws ServletException {
|
| | | }
|
| | |
|
| | | /**
|
| | | * @see javax.servlet.Filter#destroy()
|
| | | */
|
| | | @Override
|
| | | public void destroy() {
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | return user;
|
| | | }
|
| | | }
|
| | | } |
| | | }
|