Package org.tamacat.httpd.exception

Examples of org.tamacat.httpd.exception.UnauthorizedException


      Digest digest = new Digest(line);

      if (authComponent != null) {
        AuthUser user = authComponent.getAuthUser(digest.getUsername(),  context);
        String hashedPassword = null;
        if (user == null) throw new UnauthorizedException();
        if (user.isEncrypted() == false) {
          //A1 = username:realm:password
          String a1 = user.getAuthUsername() + ":"
            + realm + ":" + user.getAuthPassword();
          String hash1 = encode(getMD5(a1));
         
          //A2 = Method:URI
          String a2 = request.getRequestLine().getMethod()
            + ":" + request.getRequestLine().getUri();
          String hash2 = encode(getMD5(a2));

          //Digest = A1:nonce:nonce-count:cnonce:qop:A2
          String digestPassword = hash1 + ":" + digest.getNonce()
            + ":" + digest.getNc() + ":" + digest.getCnonce()
            + ":" + digest.getQop() + ":" + hash2;
          hashedPassword = encode(getMD5(digestPassword));
        }
        String username = digest.getUsername();
        String password = digest.getResponse();
        if (username != null && password != null
            && username.equals(user.getAuthUsername())
            && password.equals(hashedPassword)) {
          return user.getAuthUsername();
        }
      }
    }
    throw new UnauthorizedException();
  }
View Full Code Here


            && authComponent.check(user, password, context)) {
          return user;
        }
      }
    }
    throw new UnauthorizedException();
  }
View Full Code Here

        context.setAttribute(SC_AUTHORIZED, Boolean.TRUE);
      } else if (StringUtils.isNotEmpty(sessionId)) {
        //already login. -> session check
        Session session = SessionManager.getInstance().getSession(sessionId, false);
        if (session == null) { //invalid session.
          throw new UnauthorizedException();
        }
        remoteUser = (String) session.getAttribute(sessionUsernameKey);
        if (remoteUser == null) { //invalid session.
          throw new UnauthorizedException();
        }
        context.setAttribute(remoteUserKey, remoteUser);
        if (path.endsWith(logoutActionUrl)) {
          //logout -> session delete -> login page.
          logoutAction(request, sessionId);
          //force login page.
          //context.setAttribute(SC_UNAUTHORIZED, Boolean.TRUE);
        } else {
          //OK
        }
      } else { //It does not yet login.
        throw new UnauthorizedException();
      }
    } catch (UnauthorizedException e) {
      logoutAction(request, sessionId);
      response.setStatusCode(HttpStatus.SC_UNAUTHORIZED);
      context.setAttribute(SC_UNAUTHORIZED, Boolean.TRUE);
View Full Code Here

      response.setHeader(HTTP.CONTENT_TYPE, "text/html; charset=" + charset);
      response.setEntity(new StringEntity(
        "<html><meta http-equiv=\"refresh\" content=\"0;url="
          + uri + "\"></html>", "UTF-8"));
    } catch (UnsupportedEncodingException e) {
      throw new UnauthorizedException();
    }
  }
View Full Code Here

      if (authComponent != null
          && authComponent.check(username, password, context)) {
        return username;
      }
    }
    throw new UnauthorizedException();
  }
View Full Code Here

            && password.equals(passwordDigest)) {
          return user.getAuthUsername();
        }
      }
    }
      throw new UnauthorizedException();
  }
View Full Code Here

  protected String getPasswordDigest(WSSE wsse, AuthUser user) {
    String password = user.getAuthPassword();
    if (password == null
        || wsse.getNonce() == null
        || wsse.getCreated() == null) {
      throw new UnauthorizedException();
    }
    byte[] nonce = new Base64().decode(wsse.getNonce().getBytes());
    byte[] created = wsse.getCreated().getBytes();
    byte[] pb = password.getBytes();
    byte[] digest = new byte[nonce.length + created.length + pb.length];
View Full Code Here

        response.setHeader("Set-Cookie", singleSignOnCookieName + "=" + remoteUser + "; Path=/");
        request.setHeader("Cookie",  singleSignOnCookieName + "=" + remoteUser); //for Reverse Proxy
        LOG.trace("Set-Cookie: " + singleSignOnCookieName + "=" + remoteUser + "; Path=/");
      }
    } else {
      throw new UnauthorizedException();
    }
  }
View Full Code Here

TOP

Related Classes of org.tamacat.httpd.exception.UnauthorizedException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.