Example usage for javax.servlet.http HttpServletRequest getRemoteHost

List of usage examples for javax.servlet.http HttpServletRequest getRemoteHost

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getRemoteHost.

Prototype

public String getRemoteHost();

Source Link

Document

Returns the fully qualified name of the client or the last proxy that sent the request.

Usage

From source file:org.jumpmind.symmetric.web.RegistrationUriHandler.java

protected String getHostName(HttpServletRequest req) {
    String hostName = ServletUtils.getParameter(req, WebConstants.HOST_NAME);
    if (StringUtils.isBlank(hostName)) {
        hostName = req.getRemoteHost();
    }/*  w  w  w  .j  a  v a 2s  .c o m*/
    return hostName;
}

From source file:MyServlet.java

public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    // Get the client's hostname
    String remoteHost = req.getRemoteHost();

    out.println("remoteHost:" + remoteHost);
    // See if the client is allowed
    if (!isHostAllowed(remoteHost)) {
        out.println("Access <BLINK>denied</BLINK>");
    } else {/*from  w  ww  . j a  va  2s. co m*/
        out.println("Access granted");
        // Display download links, etc...
    }
}

From source file:org.tsm.concharto.web.feedback.FeedbackController.java

@SuppressWarnings("unchecked")
private String getBrowserInfo(HttpServletRequest request) {
    StringBuffer userRequestInfo = new StringBuffer().append(request.getRemoteAddr()).append("\n")
            .append(request.getRemoteHost()).append("\n");

    Enumeration headerNames = request.getHeaderNames();
    while (headerNames.hasMoreElements()) {
        String headerName = (String) headerNames.nextElement();
        //don't email cookies for security reasons
        if (!"cookie".equals(headerName)) {
            userRequestInfo.append(headerName).append(": ").append(request.getHeader(headerName)).append("\n");
        }/*www. jav a2 s.  com*/

    }
    return userRequestInfo.toString();
}

From source file:ExportRestriction.java

public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    // Get the client's hostname
    String remoteHost = req.getRemoteHost();

    // See if the client is allowed
    if (!isHostAllowed(remoteHost)) {
        out.println("Access <BLINK>denied</BLINK>");
    } else {/*from  ww w.java 2s.  c  om*/
        out.println("Access granted");
        // Display download links, etc...
    }
}

From source file:io.hops.hopsworks.common.dao.user.security.audit.AccountAuditFacade.java

public void registerLoginInfo(Users user, String action, String outcome, HttpServletRequest req) {
    if (!whitelistUserLogins.contains(user.getEmail())) {
        Userlogins userlogin = new Userlogins(req.getRemoteHost(), extractUserAgent(req), user, action, outcome,
                new Date());
        em.persist(userlogin);//ww  w  .  j a  v a  2  s  . c o  m
    }
}

From source file:io.hops.hopsworks.common.dao.user.security.audit.AccountAuditFacade.java

public void registerRoleChange(Users user, String action, String outcome, String message, Users targetUser,
        HttpServletRequest req) {
    RolesAudit rolesAudit = new RolesAudit(action, new Date(), message, extractUserAgent(req),
            req.getRemoteHost(), outcome, targetUser, user);
    em.persist(rolesAudit);//from w ww  . ja va2 s.c o m
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.authenticate.FriendController.java

private void writeWarningToTheLog(HttpServletRequest req) {
    log.warn("LOGGING IN VIA FRIEND FROM ADDR=" + req.getRemoteAddr() + ", PORT=" + req.getRemotePort()
            + ", HOST=" + req.getRemoteHost() + ", USER=" + req.getRemoteUser());
}

From source file:eu.eidas.node.AbstractSpecificServlet.java

@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    if (!StringUtils.isEmpty(request.getRemoteHost())) {
        MDC.put(MDC_REMOTE_HOST, request.getRemoteHost());
    }/*w  w w .  ja v a2 s. c  om*/
    MDC.put(MDC_SESSIONID, request.getSession().getId());
    getLogger().info(WEB_EVENT,
            "**** CALL to servlet " + this.getClass().getName() + "FROM " + request.getRemoteAddr() + "HTTP "
                    + request.getMethod() + " SESSIONID " + request.getSession().getId() + "****");

    super.service(request, response);
}

From source file:edu.uiowa.icts.authentication.AuthHandle.java

/** {@inheritDoc} */
@Override/*from   w w w.j a v  a  2s.c  o m*/
public void onAuthenticationFailure(HttpServletRequest req, HttpServletResponse res,
        AuthenticationException excep) throws IOException, ServletException {
    AuditLogger.info("NONE", req.getParameter("j_username"), "Error logging in from " + req.getRemoteHost(),
            excep.getMessage());
    req.getSession().setAttribute("SPRING_SECURITY_LAST_EXCEPTION", excep);
    redirectStrategy.sendRedirect(req, res, "/login.html?error=true");
}

From source file:org.polymap.core.workbench.dnd.DndUploadServlet.java

protected String findClientIP(HttpServletRequest request) {
    String forwarded = request.getHeader("X-Forwarded-For");
    if (forwarded != null) {
        return forwarded;
    } else {//  www  .j  a v  a 2s .  c  o  m
        return request.getRemoteHost();
    }
}