James Moger
2012-11-28 b718540114103aaad2fd2554745fdb61d1e6cd17
src/com/gitblit/AuthenticationFilter.java
@@ -69,6 +69,15 @@
   @Override
   public abstract void doFilter(final ServletRequest request, final ServletResponse response,
         final FilterChain chain) throws IOException, ServletException;
   /**
    * Allow the filter to require a client certificate to continue processing.
    *
    * @return true, if a client certificate is required
    */
   protected boolean requiresClientCertificate() {
      return false;
   }
   /**
    * Returns the full relative url of the request.
@@ -95,6 +104,16 @@
    */
   protected UserModel getUser(HttpServletRequest httpRequest) {
      UserModel user = null;
      // try request authentication
      user = GitBlit.self().authenticate(httpRequest);
      if (user != null) {
         return user;
      } else if (requiresClientCertificate()) {
         // http request does not have a valid certificate
         // and the filter requires one
         return null;
      }
      // look for client authorization credentials in header
      final String authorization = httpRequest.getHeader("Authorization");
      if (authorization != null && authorization.startsWith(BASIC)) {
@@ -103,7 +122,7 @@
         String credentials = new String(Base64.decode(base64Credentials),
               Charset.forName("UTF-8"));
         // credentials = username:password
         final String[] values = credentials.split(":");
         final String[] values = credentials.split(":",2);
         if (values.length == 2) {
            String username = values[0];
@@ -170,6 +189,7 @@
      public AuthenticatedRequest(HttpServletRequest req) {
         super(req);
         user = new UserModel("anonymous");
         user.isAuthenticated = false;
      }
      UserModel getUser() {
@@ -188,7 +208,7 @@
      @Override
      public boolean isUserInRole(String role) {
         if (role.equals(Constants.ADMIN_ROLE)) {
            return user.canAdmin;
            return user.canAdmin();
         }
         // Gitblit does not currently use actual roles in the traditional
         // servlet container sense.  That is the reason this is marked