List of usage examples for javax.servlet.http HttpServletRequest getAuthType
public String getAuthType();
From source file:fr.paris.lutece.util.http.SecurityUtil.java
/** * Write request variables into the dump stringbuffer * @param sb The dump stringbuffer/*from w w w. ja v a 2 s . com*/ * @param request The HTTP request */ private static void dumpVariables(StringBuffer sb, HttpServletRequest request) { dumpVariable(sb, "AUTH_TYPE", request.getAuthType()); dumpVariable(sb, "REQUEST_METHOD", request.getMethod()); dumpVariable(sb, "PATH_INFO", request.getPathInfo()); dumpVariable(sb, "PATH_TRANSLATED", request.getPathTranslated()); dumpVariable(sb, "QUERY_STRING", request.getQueryString()); dumpVariable(sb, "REQUEST_URI", request.getRequestURI()); dumpVariable(sb, "SCRIPT_NAME", request.getServletPath()); dumpVariable(sb, "LOCAL_ADDR", request.getLocalAddr()); dumpVariable(sb, "SERVER_PROTOCOL", request.getProtocol()); dumpVariable(sb, "REMOTE_ADDR", request.getRemoteAddr()); dumpVariable(sb, "REMOTE_HOST", request.getRemoteHost()); dumpVariable(sb, "HTTPS", request.getScheme()); dumpVariable(sb, "SERVER_NAME", request.getServerName()); dumpVariable(sb, "SERVER_PORT", String.valueOf(request.getServerPort())); }
From source file:org.apache.struts.faces.systest1.ContextAction.java
/** * <p>Process an attempted logon.</p> *//* w w w . j av a2 s .c om*/ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { this.authType = request.getAuthType(); this.contextPath = request.getContextPath(); this.locale = request.getLocale(); this.pathInfo = request.getPathInfo(); this.remoteUser = request.getRemoteUser(); this.servletPath = request.getServletPath(); request.setAttribute("contextAction", this); return (mapping.findForward("context1")); }
From source file:edu.stanford.epad.epadws.security.EPADSessionOperations.java
public static EPADSessionResponse authenticateUser(HttpServletRequest httpRequest) { String username = extractUserNameFromAuthorizationHeader(httpRequest); String password = extractPasswordFromAuthorizationHeader(httpRequest); if (username == null || username.length() == 0) { username = httpRequest.getParameter("username"); password = httpRequest.getParameter("password"); }//from ww w. j a v a 2 s. co m EPADSession session = null; try { if (username != null && password == null && httpRequest.getParameter("adminuser") != null) { session = EPADSessionOperations.createProxySession(username, httpRequest.getParameter("adminuser"), httpRequest.getParameter("adminpassword")); } else if (username == null && httpRequest.getAuthType().equals("WebAuth") && httpRequest.getRemoteUser() != null) { if (password != null && password.equals(EPADConfig.webAuthPassword)) session = EPADSessionOperations.createPreAuthenticatedSession(httpRequest.getRemoteUser()); } else { session = EPADSessionOperations.createNewEPADSession(username, password); } EPADSessionResponse response = new EPADSessionResponse(HttpServletResponse.SC_OK, session.getSessionId(), ""); log.info("Session ID " + response.response + " generated for user " + username); return response; } catch (Exception x) { EPADSessionResponse response = new EPADSessionResponse(HttpServletResponse.SC_UNAUTHORIZED, null, x.getMessage()); return response; } }
From source file:org.wso2.carbon.identity.authenticator.iwa.ui.IWAUIAuthenticator.java
/** * {@inheritDoc}/*from w w w . ja va 2s.c o m*/ */ @Override public boolean canHandle(HttpServletRequest request) { if ((NEGOTIATE.equalsIgnoreCase(request.getAuthType()) || NTLM.equalsIgnoreCase(request.getAuthType())) && request.getRemoteUser() != null) { if (log.isDebugEnabled()) { log.debug("IWA request received for url: " + request.getRequestURL() + " Auth type:" + request.getAuthType()); } return true; } return false; }
From source file:com.redhat.rhn.frontend.servlets.DumpFilter.java
/** {@inheritDoc} */ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { if (log.isDebugEnabled()) { // handle request HttpServletRequest request = (HttpServletRequest) req; log.debug("Entered doFilter() ==================================="); log.debug("AuthType: " + request.getAuthType()); log.debug("Method: " + request.getMethod()); log.debug("PathInfo: " + request.getPathInfo()); log.debug("Translated path: " + request.getPathTranslated()); log.debug("ContextPath: " + request.getContextPath()); log.debug("Query String: " + request.getQueryString()); log.debug("Remote User: " + request.getRemoteUser()); log.debug("Remote Host: " + request.getRemoteHost()); log.debug("Remote Addr: " + request.getRemoteAddr()); log.debug("SessionId: " + request.getRequestedSessionId()); log.debug("uri: " + request.getRequestURI()); log.debug("url: " + request.getRequestURL().toString()); log.debug("Servlet path: " + request.getServletPath()); log.debug("Server Name: " + request.getServerName()); log.debug("Server Port: " + request.getServerPort()); log.debug("RESPONSE encoding: " + resp.getCharacterEncoding()); log.debug("REQUEST encoding: " + request.getCharacterEncoding()); log.debug("JVM encoding: " + System.getProperty("file.encoding")); logSession(request.getSession()); logHeaders(request);/* w ww .jav a 2s .com*/ logCookies(request.getCookies()); logParameters(request); logAttributes(request); log.debug("Calling chain.doFilter() -----------------------------"); } chain.doFilter(req, resp); if (log.isDebugEnabled()) { log.debug("Returned from chain.doFilter() -----------------------"); log.debug("Handle Response, not much to print"); log.debug("Response: " + resp.toString()); log.debug("Leaving doFilter() ==================================="); } }
From source file:org.smigo.log.LogHandler.java
public String getRequestDump(HttpServletRequest request, HttpServletResponse response, String separator) { StringBuilder s = new StringBuilder("####REQUEST ").append(request.getMethod()).append(" ") .append(request.getRequestURL()).append(separator); s.append("Auth type:").append(request.getAuthType()).append(separator); s.append("Principal:").append(request.getUserPrincipal()).append(separator); s.append(Log.create(request, response).toString()).append(separator); s.append("Headers:").append(separator); Enumeration<String> headerNames = request.getHeaderNames(); while (headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); s.append(headerName).append("=").append(request.getHeader(headerName)).append(separator); }// w ww. j ava2 s . c o m s.append(separator); s.append("####RESPONSE").append(separator); s.append("Status:").append(response.getStatus()).append(separator); s.append("Char encoding:").append(response.getCharacterEncoding()).append(separator); s.append("Locale:").append(response.getLocale()).append(separator); s.append("Content type:").append(response.getContentType()).append(separator); s.append("Headers:").append(separator); s.append(response.getHeaderNames().stream().map(rh -> rh + "=" + response.getHeader(rh)) .collect(Collectors.joining(separator))); final Long start = (Long) request.getAttribute(RequestLogFilter.REQUEST_TIMER); if (start != null) { final long elapsedTime = System.nanoTime() - start; s.append(separator).append("####Request time elapsed:").append(elapsedTime); s.append("ns which is ").append(elapsedTime / 1000000).append("ms").append(separator); } return s.toString(); }
From source file:org.apache.hadoop.http.HttpServer2.java
/** * check whether user is static and unauthenticated, if the * answer is TRUE, that means http sever is in non-security * environment.//ww w. j a v a 2 s. c o m * @param servletContext the servlet context. * @param request the servlet request. * @return TRUE/FALSE based on the logic described above. */ public static boolean isStaticUserAndNoneAuthType(ServletContext servletContext, HttpServletRequest request) { Configuration conf = (Configuration) servletContext.getAttribute(CONF_CONTEXT_ATTRIBUTE); final String authType = request.getAuthType(); final String staticUser = conf.get(CommonConfigurationKeys.HADOOP_HTTP_STATIC_USER, CommonConfigurationKeys.DEFAULT_HADOOP_HTTP_STATIC_USER); return authType == null && staticUser.equals(request.getRemoteUser()); }
From source file:org.ngrinder.script.controller.SvnDavController.java
@SuppressWarnings("StringConcatenationInsideStringBufferAppend") private void logRequest(HttpServletRequest request) { StringBuilder logBuffer = new StringBuilder(); logBuffer.append('\n'); logBuffer.append("request.getAuthType(): " + request.getAuthType()); logBuffer.append('\n'); logBuffer.append("request.getCharacterEncoding(): " + request.getCharacterEncoding()); logBuffer.append('\n'); logBuffer.append("request.getContentType(): " + request.getContentType()); logBuffer.append('\n'); logBuffer.append("request.getContextPath(): " + request.getContextPath()); logBuffer.append('\n'); logBuffer.append("request.getContentLength(): " + request.getContentLength()); logBuffer.append('\n'); logBuffer.append("request.getMethod(): " + request.getMethod()); logBuffer.append('\n'); logBuffer.append("request.getPathInfo(): " + request.getPathInfo()); logBuffer.append('\n'); logBuffer.append("request.getPathTranslated(): " + request.getPathTranslated()); logBuffer.append('\n'); logBuffer.append("request.getQueryString(): " + request.getQueryString()); logBuffer.append('\n'); logBuffer.append("request.getRemoteAddr(): " + request.getRemoteAddr()); logBuffer.append('\n'); logBuffer.append("request.getRemoteHost(): " + request.getRemoteHost()); logBuffer.append('\n'); logBuffer.append("request.getRemoteUser(): " + request.getRemoteUser()); logBuffer.append('\n'); logBuffer.append("request.getRequestURI(): " + request.getRequestURI()); logBuffer.append('\n'); logBuffer.append("request.getServerName(): " + request.getServerName()); logBuffer.append('\n'); logBuffer.append("request.getServerPort(): " + request.getServerPort()); logBuffer.append('\n'); logBuffer.append("request.getServletPath(): " + request.getServletPath()); logBuffer.append('\n'); logBuffer.append("request.getRequestURL(): " + request.getRequestURL()); LOGGER.trace(logBuffer.toString());// w w w .j a v a 2s .com }
From source file:org.wso2.carbon.identity.authenticator.iwa.ui.IWAUIAuthenticator.java
/** * {@inheritDoc}//from ww w . ja va2 s . com */ @Override public void authenticate(HttpServletRequest request) throws AuthenticationException { String userName = request.getRemoteUser(); userName = userName.substring(userName.indexOf("\\") + 1); if (log.isDebugEnabled()) { log.debug( "Authenticate request received : Authtype - " + request.getAuthType() + ", User - " + userName); } ServletContext servletContext = request.getSession().getServletContext(); HttpSession session = request.getSession(); String backendServerURL = request.getParameter("backendURL"); if (backendServerURL == null) { backendServerURL = CarbonUIUtil.getServerURL(servletContext, request.getSession()); } session.setAttribute(CarbonConstants.SERVER_URL, backendServerURL); String rememberMe = request.getParameter("rememberMe"); handleSecurity(userName, (rememberMe != null), request); request.setAttribute("username", userName); }
From source file:org.ngrinder.script.controller.DavSvnController.java
private void logRequest(HttpServletRequest request) { StringBuilder logBuffer = new StringBuilder(); logBuffer.append('\n'); logBuffer.append("request.getAuthType(): " + request.getAuthType()); logBuffer.append('\n'); logBuffer.append("request.getCharacterEncoding(): " + request.getCharacterEncoding()); logBuffer.append('\n'); logBuffer.append("request.getContentType(): " + request.getContentType()); logBuffer.append('\n'); logBuffer.append("request.getContextPath(): " + request.getContextPath()); logBuffer.append('\n'); logBuffer.append("request.getContentLength(): " + request.getContentLength()); logBuffer.append('\n'); logBuffer.append("request.getMethod(): " + request.getMethod()); logBuffer.append('\n'); logBuffer.append("request.getPathInfo(): " + request.getPathInfo()); logBuffer.append('\n'); logBuffer.append("request.getPathTranslated(): " + request.getPathTranslated()); logBuffer.append('\n'); logBuffer.append("request.getQueryString(): " + request.getQueryString()); logBuffer.append('\n'); logBuffer.append("request.getRemoteAddr(): " + request.getRemoteAddr()); logBuffer.append('\n'); logBuffer.append("request.getRemoteHost(): " + request.getRemoteHost()); logBuffer.append('\n'); logBuffer.append("request.getRemoteUser(): " + request.getRemoteUser()); logBuffer.append('\n'); logBuffer.append("request.getRequestURI(): " + request.getRequestURI()); logBuffer.append('\n'); logBuffer.append("request.getServerName(): " + request.getServerName()); logBuffer.append('\n'); logBuffer.append("request.getServerPort(): " + request.getServerPort()); logBuffer.append('\n'); logBuffer.append("request.getServletPath(): " + request.getServletPath()); logBuffer.append('\n'); logBuffer.append("request.getRequestURL(): " + request.getRequestURL()); LOGGER.trace(logBuffer.toString());//w ww.j a va 2s . co m }