indent, javadoc and removed unused import

This commit is contained in:
Sebastian Sdorra
2014-03-11 18:59:59 +01:00
parent 7c1f746def
commit 27f3286e9d

View File

@@ -35,7 +35,6 @@ package sonia.scm.web.filter;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Strings;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -84,7 +83,8 @@ public class BasicAuthenticationFilter extends AutoLoginFilter
/** Field description */ /** Field description */
public static final String HEADER_AUTHORIZATION = "Authorization"; public static final String HEADER_AUTHORIZATION = "Authorization";
/** marker for failed authentication */
private static final String ATTRIBUTE_FAILED_AUTH = "sonia.scm.auth.failed"; private static final String ATTRIBUTE_FAILED_AUTH = "sonia.scm.auth.failed";
/** the logger for BasicAuthenticationFilter */ /** the logger for BasicAuthenticationFilter */
@@ -197,7 +197,7 @@ public class BasicAuthenticationFilter extends AutoLoginFilter
} }
/** /**
* Sends status code 403 back to client, if the authentication has failed. * Sends status code 403 back to client, if the authentication has failed.
* In all other cases the method will send status code 403 back to client. * In all other cases the method will send status code 403 back to client.
* *
* @param request servlet request * @param request servlet request
@@ -213,6 +213,7 @@ public class BasicAuthenticationFilter extends AutoLoginFilter
HttpServletResponse response, FilterChain chain) HttpServletResponse response, FilterChain chain)
throws IOException, ServletException throws IOException, ServletException
{ {
// send only forbidden, if the authentication has failed. // send only forbidden, if the authentication has failed.
// see https://bitbucket.org/sdorra/scm-manager/issue/545/git-clone-with-username-in-url-does-not // see https://bitbucket.org/sdorra/scm-manager/issue/545/git-clone-with-username-in-url-does-not
if (Boolean.TRUE.equals(request.getAttribute(ATTRIBUTE_FAILED_AUTH))) if (Boolean.TRUE.equals(request.getAttribute(ATTRIBUTE_FAILED_AUTH)))
@@ -221,7 +222,8 @@ public class BasicAuthenticationFilter extends AutoLoginFilter
} }
else else
{ {
HttpUtil.sendUnauthorized(request, response, configuration.getRealmDescription()); HttpUtil.sendUnauthorized(request, response,
configuration.getRealmDescription());
} }
} }
@@ -243,7 +245,7 @@ public class BasicAuthenticationFilter extends AutoLoginFilter
String token = authentication.substring(6); String token = authentication.substring(6);
token = new String(Base64.decode(token.getBytes())); token = new String(Base64.decode(token.getBytes()));
int index = token.indexOf(CREDENTIAL_SEPARATOR); int index = token.indexOf(CREDENTIAL_SEPARATOR);
User user = null; User user = null;
@@ -268,8 +270,10 @@ public class BasicAuthenticationFilter extends AutoLoginFilter
} }
catch (AuthenticationException ex) catch (AuthenticationException ex)
{ {
// add a marker to the request that the authentication has failed // add a marker to the request that the authentication has failed
request.setAttribute(ATTRIBUTE_FAILED_AUTH, Boolean.TRUE); request.setAttribute(ATTRIBUTE_FAILED_AUTH, Boolean.TRUE);
if (logger.isTraceEnabled()) if (logger.isTraceEnabled())
{ {
logger.trace("authentication failed for user ".concat(username), logger.trace("authentication failed for user ".concat(username),