Java Code Examples for javax.servlet.ServletRequest#getRemoteHost()
The following examples show how to use
javax.servlet.ServletRequest#getRemoteHost() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StatelessFilter.java From jsets-shiro-spring-boot-starter with Apache License 2.0 | 6 votes |
protected AuthenticationToken createHmacToken(ServletRequest request, ServletResponse response) { String appId = request.getParameter(ShiroProperties.PARAM_HMAC_APP_ID); String timestamp = request.getParameter(ShiroProperties.PARAM_HMAC_TIMESTAMP); String digest= request.getParameter(ShiroProperties.PARAM_HMAC_DIGEST); List<String> parameterNames = Lists.newLinkedList(); Enumeration<String> namesEnumeration = request.getParameterNames(); while(namesEnumeration.hasMoreElements()){ String parameterName = namesEnumeration.nextElement(); parameterNames.add(parameterName); } StringBuilder baseString = new StringBuilder(); parameterNames.stream() .sorted() .forEach(name -> { if(!ShiroProperties.PARAM_HMAC_APP_ID.equals(name) &&!ShiroProperties.PARAM_HMAC_TIMESTAMP.equals(name) &&!ShiroProperties.PARAM_HMAC_DIGEST.equals(name)) baseString.append(request.getParameter(name)); }); baseString.append(appId); baseString.append(timestamp); String host = request.getRemoteHost(); return new HmacToken( host, appId, timestamp, baseString.toString(), digest); }
Example 2
Source File: JolokiaFilter.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { /* * this is the only place we can catch the remote address of the calling console client thru Jolokia. * We set the address on the calling thread which will end up in JMX audit logging * */ if (AuditLogger.isAnyLoggingEnabled() && servletRequest != null) { String remoteHost = servletRequest.getRemoteHost(); AuditLogger.setRemoteAddress(remoteHost + ":" + servletRequest.getRemotePort()); } filterChain.doFilter(servletRequest, servletResponse); /* * This is the only place we can get access to the authenticated subject on invocations after the login has happened. * we set the subject for audit logging * */ if (AuditLogger.isAnyLoggingEnabled()) { try { HttpSession session = ((Request) servletRequest).getSession(); Subject subject = (Subject) session.getAttribute("subject"); AuditLogger.setCurrentCaller(subject); } catch (Throwable e) { //best effort } } }
Example 3
Source File: JwtAuthcFilter.java From zhcc-server with Apache License 2.0 | 5 votes |
@Override protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception { //从header中得到token String token = ((HttpServletRequest)request).getHeader("X-Token"); String host = request.getRemoteHost(); JwtToken jwtToken = new JwtToken(token, host); try { //委托给Realm进行登录 getSubject(request, response).login(jwtToken); } catch (Exception e) { return false; } return true; }
Example 4
Source File: HttpRequestUtil.java From nifi-minifi with Apache License 2.0 | 5 votes |
public static String getClientString(ServletRequest request) { String remoteHost = request.getRemoteHost(); String remoteAddr = request.getRemoteAddr(); String result = "Client " + remoteHost; if (!remoteAddr.equals(remoteHost)) { result = result + " (" + remoteAddr + ")"; } return result; }
Example 5
Source File: ApiKeyAuthenticationFilter.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Override protected AuthenticationToken createToken(final ServletRequest request, final ServletResponse response) { final String principal = (String) request.getAttribute(NX_APIKEY_PRINCIPAL); final String token = (String) request.getAttribute(NX_APIKEY_TOKEN); if (!Strings2.isBlank(principal) && !Strings2.isBlank(token)) { return new NexusApiKeyAuthenticationToken(principal, token.toCharArray(), request.getRemoteHost()); } return super.createToken(request, response); }
Example 6
Source File: HttpRequestSessionManager.java From usergrid with Apache License 2.0 | 5 votes |
private String getHost( SessionContext context ) { String host = context.getHost(); if ( host == null ) { ServletRequest request = WebUtils.getRequest( context ); if ( request != null ) { host = request.getRemoteHost(); } } return host; }
Example 7
Source File: StatelessFilter.java From jsets-shiro-spring-boot-starter with Apache License 2.0 | 4 votes |
protected AuthenticationToken createJwtToken(ServletRequest request, ServletResponse response) { String host = request.getRemoteHost(); String jwt = request.getParameter(ShiroProperties.PARAM_JWT); return new JwtToken(host,jwt); }
Example 8
Source File: AllowAllFilter.java From airpal with Apache License 2.0 | 4 votes |
@Override protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) throws Exception { log.info("createToken called"); return new AllowAllToken(request.getRemoteHost(), true, "anonymous", ImmutableSet.of("all"), "default", Duration.standardHours(1), "default"); }
Example 9
Source File: AuthenticatingFilter.java From tapestry-security with Apache License 2.0 | 2 votes |
/** * Returns the host name or IP associated with the current subject. This method is primarily provided for use * during construction of an <code>AuthenticationToken</code>. * <p/> * The default implementation merely returns {@link ServletRequest#getRemoteHost()}. * * @param request the incoming ServletRequest * @return the <code>InetAddress</code> to associate with the login attempt. */ protected String getHost(ServletRequest request) { return request.getRemoteHost(); }