Package org.apache.juddi.portlets.client.service

Examples of org.apache.juddi.portlets.client.service.SecurityResponse


  public SecurityResponse get(String username, String password) {
    HttpServletRequest request = getThreadLocalRequest();
    HttpSession session = request.getSession();
   
    log.debug("User " + username + " sending token request..");
    SecurityResponse response = new SecurityResponse();
    String token = (String) session.getAttribute("AuthToken");
    if (username==null) {
      username = (String) session.getAttribute("UserName");
    }
    Principal user = request.getUserPrincipal();
    log.debug("UserPrincipal " + user);
    if (username==null && user!=null) {
      username = user.getName();
      password = "";
    }
    if (token==null) {
      if (username==null) {
        log("Could not obtain username, this session is invalid.");
        response.setSuccess(false);
        return response;
      } else {
        try {
          AuthToken authToken = login(username, password, session.getServletContext());
          response.setSuccess(true);
          response.setResponse(authToken.getAuthInfo());
          session.setAttribute("AuthToken", authToken.getAuthInfo());
          session.setAttribute("UserName", username);
         
            setClerkAuthenticationTokensInSession(username);
        } catch (Exception e) {
          log.error("Could not obtain token. " + e.getMessage(), e);
          response.setSuccess(false);
          response.setMessage(e.getMessage());
          response.setErrorCode("101");
        } catch (Throwable t) {
          log.error("Could not obtain token. " + t.getMessage(), t);
          response.setSuccess(false);
          response.setMessage(t.getMessage());
          response.setErrorCode("101");
        }
      }
    } else {
      try {
        setClerkAuthenticationTokensInSession(username);
        response.setSuccess(true);
        response.setResponse(token);
      } catch (Exception e) {
        log.error("Could not obtain token. " + e.getMessage(), e);
        response.setSuccess(false);
        response.setMessage(e.getMessage());
        response.setErrorCode("101");
      } catch (Throwable t) {
        log.error("Could not obtain token. " + t.getMessage(), t);
        response.setSuccess(false);
        response.setMessage(t.getMessage());
        response.setErrorCode("101");
      }
    }
    response.setUsername(username);
    return response;
  }
View Full Code Here

TOP

Related Classes of org.apache.juddi.portlets.client.service.SecurityResponse

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.