Java 类org.apache.catalina.AccessLog 实例源码

项目:tomcat7    文件:ContainerBase.java   
@Override
public AccessLog getAccessLog() {

    if (accessLogScanComplete) {
        return accessLog;
    }

    AccessLogAdapter adapter = null;
    Valve valves[] = getPipeline().getValves();
    for (Valve valve : valves) {
        if (valve instanceof AccessLog) {
            if (adapter == null) {
                adapter = new AccessLogAdapter((AccessLog) valve);
            } else {
                adapter.add((AccessLog) valve);
            }
        }
    }
    if (adapter != null) {
        accessLog = adapter;
    }
    accessLogScanComplete = true;
    return accessLog;
}
项目:tomcat7    文件:TestRemoteIpValve.java   
@Test
public void testRequestAttributesForAccessLog() throws Exception {

    // PREPARE
    RemoteIpValve remoteIpValve = new RemoteIpValve();
    remoteIpValve.setRemoteIpHeader("x-forwarded-for");
    remoteIpValve.setProtocolHeader("x-forwarded-proto");
    RemoteAddrAndHostTrackerValve remoteAddrAndHostTrackerValve = new RemoteAddrAndHostTrackerValve();
    remoteIpValve.setNext(remoteAddrAndHostTrackerValve);

    Request request = new MockRequest();
    request.setCoyoteRequest(new org.apache.coyote.Request());
    // client ip
    request.setRemoteAddr("192.168.0.10");
    request.setRemoteHost("192.168.0.10");
    request.getCoyoteRequest().getMimeHeaders().addValue("x-forwarded-for").setString("140.211.11.130");
    // protocol
    request.setServerPort(8080);
    request.getCoyoteRequest().scheme().setString("http");

    // TEST
    remoteIpValve.invoke(request, null);

    // VERIFY
    Assert.assertEquals("org.apache.catalina.AccessLog.ServerPort",
            Integer.valueOf(8080),
            request.getAttribute(AccessLog.SERVER_PORT_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteAddr",
            "140.211.11.130",
            request.getAttribute(AccessLog.REMOTE_ADDR_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteHost",
            "140.211.11.130",
            request.getAttribute(AccessLog.REMOTE_HOST_ATTRIBUTE));
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestRemoteIpValve.java   
@Test
public void testRequestAttributesForAccessLog() throws Exception {

    // PREPARE
    RemoteIpValve remoteIpValve = new RemoteIpValve();
    remoteIpValve.setRemoteIpHeader("x-forwarded-for");
    remoteIpValve.setProtocolHeader("x-forwarded-proto");
    RemoteAddrAndHostTrackerValve remoteAddrAndHostTrackerValve = new RemoteAddrAndHostTrackerValve();
    remoteIpValve.setNext(remoteAddrAndHostTrackerValve);

    Request request = new MockRequest();
    request.setCoyoteRequest(new org.apache.coyote.Request());
    // client ip
    request.setRemoteAddr("192.168.0.10");
    request.setRemoteHost("192.168.0.10");
    request.getCoyoteRequest().getMimeHeaders().addValue("x-forwarded-for").setString("140.211.11.130");
    // protocol
    request.setServerPort(8080);
    request.getCoyoteRequest().scheme().setString("http");

    // TEST
    remoteIpValve.invoke(request, null);

    // VERIFY
    Assert.assertEquals("org.apache.catalina.AccessLog.ServerPort",
            Integer.valueOf(8080),
            request.getAttribute(AccessLog.SERVER_PORT_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteAddr",
            "140.211.11.130",
            request.getAttribute(AccessLog.REMOTE_ADDR_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteHost",
            "140.211.11.130",
            request.getAttribute(AccessLog.REMOTE_HOST_ATTRIBUTE));
}
项目:lazycat    文件:ContainerBase.java   
@Override
public AccessLog getAccessLog() {

    if (accessLogScanComplete) {
        return accessLog;
    }

    AccessLogAdapter adapter = null;
    Valve valves[] = getPipeline().getValves();
    for (Valve valve : valves) {
        if (valve instanceof AccessLog) {
            if (adapter == null) {
                adapter = new AccessLogAdapter((AccessLog) valve);
            } else {
                adapter.add((AccessLog) valve);
            }
        }
    }
    if (adapter != null) {
        accessLog = adapter;
    }
    accessLogScanComplete = true;
    return accessLog;
}
项目:class-guard    文件:ContainerBase.java   
@Override
public AccessLog getAccessLog() {

    if (accessLogScanComplete) {
        return accessLog;
    }

    AccessLogAdapter adapter = null;
    Valve valves[] = getPipeline().getValves();
    for (Valve valve : valves) {
        if (valve instanceof AccessLog) {
            if (adapter == null) {
                adapter = new AccessLogAdapter((AccessLog) valve);
            } else {
                adapter.add((AccessLog) valve);
            }
        }
    }
    if (adapter != null) {
        accessLog = adapter;
    }
    accessLogScanComplete = true;
    return accessLog;
}
项目:apache-tomcat-7.0.57    文件:ContainerBase.java   
@Override
public AccessLog getAccessLog() {

    if (accessLogScanComplete) {
        return accessLog;
    }

    AccessLogAdapter adapter = null;
    Valve valves[] = getPipeline().getValves();
    for (Valve valve : valves) {
        if (valve instanceof AccessLog) {
            if (adapter == null) {
                adapter = new AccessLogAdapter((AccessLog) valve);
            } else {
                adapter.add((AccessLog) valve);
            }
        }
    }
    if (adapter != null) {
        accessLog = adapter;
    }
    accessLogScanComplete = true;
    return accessLog;
}
项目:apache-tomcat-7.0.57    文件:ContainerBase.java   
@Override
public AccessLog getAccessLog() {

    if (accessLogScanComplete) {
        return accessLog;
    }

    AccessLogAdapter adapter = null;
    Valve valves[] = getPipeline().getValves();
    for (Valve valve : valves) {
        if (valve instanceof AccessLog) {
            if (adapter == null) {
                adapter = new AccessLogAdapter((AccessLog) valve);
            } else {
                adapter.add((AccessLog) valve);
            }
        }
    }
    if (adapter != null) {
        accessLog = adapter;
    }
    accessLogScanComplete = true;
    return accessLog;
}
项目:tomcat-mongo-access-log    文件:MongoAccessLogValve.java   
/**
 * Set the format pattern, first translating any recognized alias.
 *
 * @param pattern The new pattern
 */
public void setPattern(String pattern) {
    if (pattern == null) {
        this.pattern = "";
    } else if (pattern.equals(Constants.AccessLog.COMMON_ALIAS)) {
        this.pattern = Constants.AccessLog.COMMON_PATTERN;
    } else if (pattern.equals(Constants.AccessLog.COMBINED_ALIAS)) {
        this.pattern = Constants.AccessLog.COMBINED_PATTERN;
    } else if (pattern.equals(me.chanjar.tomcat.valves.Constants.MongoAccessLog.DEFAULT_ALIAS)) {
        this.pattern = me.chanjar.tomcat.valves.Constants.MongoAccessLog.DEFAULT_PATTERN;
    } else if (pattern.equals(me.chanjar.tomcat.valves.Constants.MongoAccessLog.ALL_ALIAS)) {
      this.pattern = me.chanjar.tomcat.valves.Constants.MongoAccessLog.ALL_PATTERN;
    } else {
        this.pattern = pattern;
    }
    logElements = createLogElements();
}
项目:WBSAirback    文件:ContainerBase.java   
@Override
public AccessLog getAccessLog() {

    if (accessLogScanComplete) {
        return accessLog;
    }

    AccessLogAdapter adapter = null;
    Valve valves[] = getPipeline().getValves();
    for (Valve valve : valves) {
        if (valve instanceof AccessLog) {
            if (adapter == null) {
                adapter = new AccessLogAdapter((AccessLog) valve);
            } else {
                adapter.add((AccessLog) valve);
            }
        }
    }
    if (adapter != null) {
        accessLog = adapter;
    }
    accessLogScanComplete = true;
    return accessLog;
}
项目:tomcat7    文件:AccessLogValve.java   
/**
 * Set the format pattern, first translating any recognized alias.
 *
 * @param pattern The new pattern
 */
public void setPattern(String pattern) {
    if (pattern == null) {
        this.pattern = "";
    } else if (pattern.equals(Constants.AccessLog.COMMON_ALIAS)) {
        this.pattern = Constants.AccessLog.COMMON_PATTERN;
    } else if (pattern.equals(Constants.AccessLog.COMBINED_ALIAS)) {
        this.pattern = Constants.AccessLog.COMBINED_PATTERN;
    } else {
        this.pattern = pattern;
    }
    logElements = createLogElements();
}
项目:tomcat7    文件:AccessLogAdapter.java   
public void add(AccessLog log) {
    if (log == null) {
        throw new NullPointerException();
    }
    AccessLog newArray[] = Arrays.copyOf(logs, logs.length + 1);
    newArray[newArray.length - 1] = log;
    logs = newArray;
}
项目:tomcat7    文件:TestRemoteIpFilter.java   
@Test
public void testRequestAttributesForAccessLog() throws Exception {
    // PREPARE
    FilterDef filterDef = new FilterDef();
    filterDef.addInitParameter("protocolHeader", "x-forwarded-proto");
    filterDef.addInitParameter("remoteIpHeader", "x-my-forwarded-for");
    filterDef.addInitParameter("httpServerPort", "8080");

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRemoteAddr("192.168.0.10");
    request.setHeader("x-my-forwarded-for", "140.211.11.130");
    request.setHeader("x-forwarded-proto", "http");

    // TEST
    HttpServletRequest actualRequest = testRemoteIpFilter(filterDef, request).getRequest();

    // VERIFY
    Assert.assertEquals("org.apache.catalina.AccessLog.ServerPort",
            Integer.valueOf(8080),
            actualRequest.getAttribute(AccessLog.SERVER_PORT_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteAddr",
            "140.211.11.130",
            actualRequest.getAttribute(AccessLog.REMOTE_ADDR_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteHost",
            "140.211.11.130",
            actualRequest.getAttribute(AccessLog.REMOTE_HOST_ATTRIBUTE));
}
项目:apache-tomcat-7.0.73-with-comment    文件:AccessLogValve.java   
/**
 * Set the format pattern, first translating any recognized alias.
 *
 * @param pattern The new pattern
 */
public void setPattern(String pattern) {
    if (pattern == null) {
        this.pattern = "";
    } else if (pattern.equals(Constants.AccessLog.COMMON_ALIAS)) {
        this.pattern = Constants.AccessLog.COMMON_PATTERN;
    } else if (pattern.equals(Constants.AccessLog.COMBINED_ALIAS)) {
        this.pattern = Constants.AccessLog.COMBINED_PATTERN;
    } else {
        this.pattern = pattern;
    }
    logElements = createLogElements();
}
项目:apache-tomcat-7.0.73-with-comment    文件:AccessLogAdapter.java   
public void add(AccessLog log) {
    if (log == null) {
        throw new NullPointerException();
    }
    AccessLog newArray[] = Arrays.copyOf(logs, logs.length + 1);
    newArray[newArray.length - 1] = log;
    logs = newArray;
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestRemoteIpFilter.java   
@Test
public void testRequestAttributesForAccessLog() throws Exception {
    // PREPARE
    FilterDef filterDef = new FilterDef();
    filterDef.addInitParameter("protocolHeader", "x-forwarded-proto");
    filterDef.addInitParameter("remoteIpHeader", "x-my-forwarded-for");
    filterDef.addInitParameter("httpServerPort", "8080");

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRemoteAddr("192.168.0.10");
    request.setHeader("x-my-forwarded-for", "140.211.11.130");
    request.setHeader("x-forwarded-proto", "http");

    // TEST
    HttpServletRequest actualRequest = testRemoteIpFilter(filterDef, request).getRequest();

    // VERIFY
    Assert.assertEquals("org.apache.catalina.AccessLog.ServerPort",
            Integer.valueOf(8080),
            actualRequest.getAttribute(AccessLog.SERVER_PORT_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteAddr",
            "140.211.11.130",
            actualRequest.getAttribute(AccessLog.REMOTE_ADDR_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteHost",
            "140.211.11.130",
            actualRequest.getAttribute(AccessLog.REMOTE_HOST_ATTRIBUTE));
}
项目:lazycat    文件:AccessLogValve.java   
/**
 * Set the format pattern, first translating any recognized alias.
 *
 * @param pattern
 *            The new pattern
 */
public void setPattern(String pattern) {
    if (pattern == null) {
        this.pattern = "";
    } else if (pattern.equals(Constants.AccessLog.COMMON_ALIAS)) {
        this.pattern = Constants.AccessLog.COMMON_PATTERN;
    } else if (pattern.equals(Constants.AccessLog.COMBINED_ALIAS)) {
        this.pattern = Constants.AccessLog.COMBINED_PATTERN;
    } else {
        this.pattern = pattern;
    }
    logElements = createLogElements();
}
项目:lazycat    文件:AccessLogAdapter.java   
public void add(AccessLog log) {
    if (log == null) {
        throw new NullPointerException();
    }
    AccessLog newArray[] = Arrays.copyOf(logs, logs.length + 1);
    newArray[newArray.length - 1] = log;
    logs = newArray;
}
项目:logback-access-spring-boot-starter    文件:TomcatLogbackAccessEvent.java   
/** {@inheritDoc} */
@Override
protected Optional<Integer> evaluateValueToOverride() {
    return Optional.of(TomcatLogbackAccessEvent.this)
            .filter(AbstractLogbackAccessEvent::isUseServerPortInsteadOfLocalPort)
            .filter(TomcatLogbackAccessEvent::isRequestAttributesEnabled)
            .map(AccessEvent::getRequest)
            .map(request -> (Integer) request.getAttribute(AccessLog.SERVER_PORT_ATTRIBUTE));
}
项目:logback-access-spring-boot-starter    文件:TomcatLogbackAccessEvent.java   
/** {@inheritDoc} */
@Override
protected Optional<String> evaluateValueToOverride() {
    return Optional.of(TomcatLogbackAccessEvent.this)
            .filter(TomcatLogbackAccessEvent::isRequestAttributesEnabled)
            .map(AccessEvent::getRequest)
            .map(request -> (String) request.getAttribute(AccessLog.REMOTE_ADDR_ATTRIBUTE));
}
项目:logback-access-spring-boot-starter    文件:TomcatLogbackAccessEvent.java   
/** {@inheritDoc} */
@Override
protected Optional<String> evaluateValueToOverride() {
    return Optional.of(TomcatLogbackAccessEvent.this)
            .filter(TomcatLogbackAccessEvent::isRequestAttributesEnabled)
            .map(AccessEvent::getRequest)
            .map(request -> (String) request.getAttribute(AccessLog.REMOTE_HOST_ATTRIBUTE));
}
项目:logback-access-spring-boot-starter    文件:TomcatLogbackAccessEvent.java   
/** {@inheritDoc} */
@Override
protected Optional<String> evaluateValueToOverride() {
    return Optional.of(TomcatLogbackAccessEvent.this)
            .filter(TomcatLogbackAccessEvent::isRequestAttributesEnabled)
            .map(AccessEvent::getRequest)
            .map(request -> (String) request.getAttribute(AccessLog.PROTOCOL_ATTRIBUTE));
}
项目:class-guard    文件:AccessLogValve.java   
/**
 * Set the format pattern, first translating any recognized alias.
 *
 * @param pattern The new pattern
 */
public void setPattern(String pattern) {
    if (pattern == null) {
        this.pattern = "";
    } else if (pattern.equals(Constants.AccessLog.COMMON_ALIAS)) {
        this.pattern = Constants.AccessLog.COMMON_PATTERN;
    } else if (pattern.equals(Constants.AccessLog.COMBINED_ALIAS)) {
        this.pattern = Constants.AccessLog.COMBINED_PATTERN;
    } else {
        this.pattern = pattern;
    }
    logElements = createLogElements();
}
项目:class-guard    文件:AccessLogAdapter.java   
public void add(AccessLog log) {
    if (log == null) {
        throw new NullPointerException();
    }
    AccessLog newArray[] = Arrays.copyOf(logs, logs.length + 1);
    newArray[newArray.length - 1] = log;
    logs = newArray;
}
项目:class-guard    文件:TestRemoteIpValve.java   
@Test
public void testRequestAttributesForAccessLog() throws Exception {

    // PREPARE
    RemoteIpValve remoteIpValve = new RemoteIpValve();
    remoteIpValve.setRemoteIpHeader("x-forwarded-for");
    remoteIpValve.setProtocolHeader("x-forwarded-proto");
    RemoteAddrAndHostTrackerValve remoteAddrAndHostTrackerValve = new RemoteAddrAndHostTrackerValve();
    remoteIpValve.setNext(remoteAddrAndHostTrackerValve);

    Request request = new MockRequest();
    request.setCoyoteRequest(new org.apache.coyote.Request());
    // client ip
    request.setRemoteAddr("192.168.0.10");
    request.setRemoteHost("192.168.0.10");
    request.getCoyoteRequest().getMimeHeaders().addValue("x-forwarded-for").setString("140.211.11.130");
    // protocol
    request.setServerPort(8080);
    request.getCoyoteRequest().scheme().setString("http");

    // TEST
    remoteIpValve.invoke(request, null);

    // VERIFY
    Assert.assertEquals("org.apache.catalina.AccessLog.ServerPort",
            Integer.valueOf(8080),
            request.getAttribute(AccessLog.SERVER_PORT_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteAddr",
            "140.211.11.130",
            request.getAttribute(AccessLog.REMOTE_ADDR_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteHost",
            "140.211.11.130",
            request.getAttribute(AccessLog.REMOTE_HOST_ATTRIBUTE));
}
项目:class-guard    文件:TestRemoteIpFilter.java   
@Test
public void testRequestAttributesForAccessLog() throws Exception {
    // PREPARE
    FilterDef filterDef = new FilterDef();
    filterDef.addInitParameter("protocolHeader", "x-forwarded-proto");
    filterDef.addInitParameter("remoteIpHeader", "x-my-forwarded-for");
    filterDef.addInitParameter("httpServerPort", "8080");

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRemoteAddr("192.168.0.10");
    request.setHeader("x-my-forwarded-for", "140.211.11.130");
    request.setHeader("x-forwarded-proto", "http");

    // TEST
    HttpServletRequest actualRequest =
            testRemoteIpFilter(filterDef, request);

    // VERIFY
    Assert.assertEquals("org.apache.catalina.AccessLog.ServerPort",
            Integer.valueOf(8080),
            actualRequest.getAttribute(AccessLog.SERVER_PORT_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteAddr",
            "140.211.11.130",
            actualRequest.getAttribute(AccessLog.REMOTE_ADDR_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteHost",
            "140.211.11.130",
            actualRequest.getAttribute(AccessLog.REMOTE_HOST_ATTRIBUTE));
}
项目:apache-tomcat-7.0.57    文件:AccessLogValve.java   
/**
 * Set the format pattern, first translating any recognized alias.
 *
 * @param pattern The new pattern
 */
public void setPattern(String pattern) {
    if (pattern == null) {
        this.pattern = "";
    } else if (pattern.equals(Constants.AccessLog.COMMON_ALIAS)) {
        this.pattern = Constants.AccessLog.COMMON_PATTERN;
    } else if (pattern.equals(Constants.AccessLog.COMBINED_ALIAS)) {
        this.pattern = Constants.AccessLog.COMBINED_PATTERN;
    } else {
        this.pattern = pattern;
    }
    logElements = createLogElements();
}
项目:apache-tomcat-7.0.57    文件:AccessLogAdapter.java   
public void add(AccessLog log) {
    if (log == null) {
        throw new NullPointerException();
    }
    AccessLog newArray[] = Arrays.copyOf(logs, logs.length + 1);
    newArray[newArray.length - 1] = log;
    logs = newArray;
}
项目:apache-tomcat-7.0.57    文件:TestRemoteIpValve.java   
@Test
public void testRequestAttributesForAccessLog() throws Exception {

    // PREPARE
    RemoteIpValve remoteIpValve = new RemoteIpValve();
    remoteIpValve.setRemoteIpHeader("x-forwarded-for");
    remoteIpValve.setProtocolHeader("x-forwarded-proto");
    RemoteAddrAndHostTrackerValve remoteAddrAndHostTrackerValve = new RemoteAddrAndHostTrackerValve();
    remoteIpValve.setNext(remoteAddrAndHostTrackerValve);

    Request request = new MockRequest();
    request.setCoyoteRequest(new org.apache.coyote.Request());
    // client ip
    request.setRemoteAddr("192.168.0.10");
    request.setRemoteHost("192.168.0.10");
    request.getCoyoteRequest().getMimeHeaders().addValue("x-forwarded-for").setString("140.211.11.130");
    // protocol
    request.setServerPort(8080);
    request.getCoyoteRequest().scheme().setString("http");

    // TEST
    remoteIpValve.invoke(request, null);

    // VERIFY
    Assert.assertEquals("org.apache.catalina.AccessLog.ServerPort",
            Integer.valueOf(8080),
            request.getAttribute(AccessLog.SERVER_PORT_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteAddr",
            "140.211.11.130",
            request.getAttribute(AccessLog.REMOTE_ADDR_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteHost",
            "140.211.11.130",
            request.getAttribute(AccessLog.REMOTE_HOST_ATTRIBUTE));
}
项目:apache-tomcat-7.0.57    文件:TestRemoteIpFilter.java   
@Test
public void testRequestAttributesForAccessLog() throws Exception {
    // PREPARE
    FilterDef filterDef = new FilterDef();
    filterDef.addInitParameter("protocolHeader", "x-forwarded-proto");
    filterDef.addInitParameter("remoteIpHeader", "x-my-forwarded-for");
    filterDef.addInitParameter("httpServerPort", "8080");

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRemoteAddr("192.168.0.10");
    request.setHeader("x-my-forwarded-for", "140.211.11.130");
    request.setHeader("x-forwarded-proto", "http");

    // TEST
    HttpServletRequest actualRequest =
            testRemoteIpFilter(filterDef, request);

    // VERIFY
    Assert.assertEquals("org.apache.catalina.AccessLog.ServerPort",
            Integer.valueOf(8080),
            actualRequest.getAttribute(AccessLog.SERVER_PORT_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteAddr",
            "140.211.11.130",
            actualRequest.getAttribute(AccessLog.REMOTE_ADDR_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteHost",
            "140.211.11.130",
            actualRequest.getAttribute(AccessLog.REMOTE_HOST_ATTRIBUTE));
}
项目:apache-tomcat-7.0.57    文件:TestRemoteIpValve.java   
@Test
public void testRequestAttributesForAccessLog() throws Exception {

    // PREPARE
    RemoteIpValve remoteIpValve = new RemoteIpValve();
    remoteIpValve.setRemoteIpHeader("x-forwarded-for");
    remoteIpValve.setProtocolHeader("x-forwarded-proto");
    RemoteAddrAndHostTrackerValve remoteAddrAndHostTrackerValve = new RemoteAddrAndHostTrackerValve();
    remoteIpValve.setNext(remoteAddrAndHostTrackerValve);

    Request request = new MockRequest();
    request.setCoyoteRequest(new org.apache.coyote.Request());
    // client ip
    request.setRemoteAddr("192.168.0.10");
    request.setRemoteHost("192.168.0.10");
    request.getCoyoteRequest().getMimeHeaders().addValue("x-forwarded-for").setString("140.211.11.130");
    // protocol
    request.setServerPort(8080);
    request.getCoyoteRequest().scheme().setString("http");

    // TEST
    remoteIpValve.invoke(request, null);

    // VERIFY
    Assert.assertEquals("org.apache.catalina.AccessLog.ServerPort",
            Integer.valueOf(8080),
            request.getAttribute(AccessLog.SERVER_PORT_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteAddr",
            "140.211.11.130",
            request.getAttribute(AccessLog.REMOTE_ADDR_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteHost",
            "140.211.11.130",
            request.getAttribute(AccessLog.REMOTE_HOST_ATTRIBUTE));
}
项目:apache-tomcat-7.0.57    文件:TestRemoteIpFilter.java   
@Test
public void testRequestAttributesForAccessLog() throws Exception {
    // PREPARE
    FilterDef filterDef = new FilterDef();
    filterDef.addInitParameter("protocolHeader", "x-forwarded-proto");
    filterDef.addInitParameter("remoteIpHeader", "x-my-forwarded-for");
    filterDef.addInitParameter("httpServerPort", "8080");

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRemoteAddr("192.168.0.10");
    request.setHeader("x-my-forwarded-for", "140.211.11.130");
    request.setHeader("x-forwarded-proto", "http");

    // TEST
    HttpServletRequest actualRequest =
            testRemoteIpFilter(filterDef, request);

    // VERIFY
    Assert.assertEquals("org.apache.catalina.AccessLog.ServerPort",
            Integer.valueOf(8080),
            actualRequest.getAttribute(AccessLog.SERVER_PORT_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteAddr",
            "140.211.11.130",
            actualRequest.getAttribute(AccessLog.REMOTE_ADDR_ATTRIBUTE));

    Assert.assertEquals("org.apache.catalina.AccessLog.RemoteHost",
            "140.211.11.130",
            actualRequest.getAttribute(AccessLog.REMOTE_HOST_ATTRIBUTE));
}
项目:apache-tomcat-7.0.57    文件:AccessLogValve.java   
/**
 * Set the format pattern, first translating any recognized alias.
 *
 * @param pattern The new pattern
 */
public void setPattern(String pattern) {
    if (pattern == null) {
        this.pattern = "";
    } else if (pattern.equals(Constants.AccessLog.COMMON_ALIAS)) {
        this.pattern = Constants.AccessLog.COMMON_PATTERN;
    } else if (pattern.equals(Constants.AccessLog.COMBINED_ALIAS)) {
        this.pattern = Constants.AccessLog.COMBINED_PATTERN;
    } else {
        this.pattern = pattern;
    }
    logElements = createLogElements();
}
项目:apache-tomcat-7.0.57    文件:AccessLogAdapter.java   
public void add(AccessLog log) {
    if (log == null) {
        throw new NullPointerException();
    }
    AccessLog newArray[] = Arrays.copyOf(logs, logs.length + 1);
    newArray[newArray.length - 1] = log;
    logs = newArray;
}
项目:WBSAirback    文件:AccessLogValve.java   
/**
 * Set the format pattern, first translating any recognized alias.
 *
 * @param pattern The new pattern
 */
public void setPattern(String pattern) {
    if (pattern == null)
        this.pattern = "";
    else if (pattern.equals(Constants.AccessLog.COMMON_ALIAS))
        this.pattern = Constants.AccessLog.COMMON_PATTERN;
    else if (pattern.equals(Constants.AccessLog.COMBINED_ALIAS))
        this.pattern = Constants.AccessLog.COMBINED_PATTERN;
    else
        this.pattern = pattern;
    logElements = createLogElements();
}
项目:WBSAirback    文件:AccessLogAdapter.java   
public void add(AccessLog log) {
    if (log == null) {
        throw new NullPointerException();
    }
    AccessLog newArray[] = Arrays.copyOf(logs, logs.length + 1);
    newArray[newArray.length - 1] = log;
    logs = newArray;
}
项目:tomcat7    文件:FailedContext.java   
@Override
public AccessLog getAccessLog() { return null; }
项目:tomcat7    文件:AccessLogAdapter.java   
public AccessLogAdapter(AccessLog log) {
    if (log == null) {
        throw new NullPointerException();
    }
    logs = new AccessLog[] { log };
}
项目:tomcat7    文件:TesterContext.java   
@Override
public AccessLog getAccessLog() {
    return null;
}
项目:tomcat7    文件:TesterHost.java   
@Override
public AccessLog getAccessLog() {
    return null;
}
项目:apache-tomcat-7.0.73-with-comment    文件:FailedContext.java   
@Override
public AccessLog getAccessLog() { return null; }