[톰캣 소스 코드 분석] 이클립스 디버깅 환경 아파치 톰캣 소스 코드에 내장

많은 기사를 컴파일 개미를 다운로드하기 위해 인터넷의 사용을 권장하지만, 반복적으로 현지 연습에 실패, 다운로드 할 수 없습니다.

나중에 https://blog.csdn.net/xiongyouqiang/article/details/78941077 완벽한 디버깅 환경을 구축하기 위해 관리 참조입니다.

다음 글은 위의 URL을 복사하지만, 약간 확장 된 거의 완벽하다.

다운로드 소스

공식 웹 사이트 소스를 다운로드

http://tomcat.apache.org/download-70.cgi 

이클립스에 소스

1 단계 : 이클립스 새로운 자바 프로젝트를 생성 톰캣-Src에있을 수 있습니다 이름과 같은

2 단계 : 프로젝트 => 가져 오기 => 일반 => 파일 시스템에 마우스 오른쪽 버튼으로 클릭, 다음 버튼을 클릭합니다.

 

3 단계 : 톰캣 소스 추출 경로, 체크 자바, 테스트의 conf의 위치를 ​​브라우저 버튼을 클릭하고 (주 예제 디렉토리를 점검 할 필요가 없습니다) webapps 디렉토리, 마침 버튼을 클릭합니다.

 

 4 단계 : 디렉토리 자바 및 테스트 => 빌드 경로 => 사용으로 소스 폴더 소스 디렉토리에이 디렉토리를 마우스 오른쪽 버튼으로 클릭합니다. 동시에 당신은 프로젝트의 원래 src 디렉토리를 삭제할 수 있습니다.

5 단계 : 가져 오기 해결 컴파일 오류 때문에 보통 특정 항아리 리드의 부족으로 프로젝트에 표시

주요 수입 전체 다음 항아리

ant.jar

ECJ-4.4.2.jar

jaxrpc.jar을

wsdl4j-1.5.2.jar 

EasyMock에-3.5.1.jar

빌드 경로에있는 lib 디렉토리, 디렉토리에이 항아리 패키지 및 추가에서 새 프로젝트에서.

아파치는 단위 테스트 도구 Junit와 같은 JUnit을을 사용하여 톰캣 우리는 프로젝트에 대한 지원을 추가 할 필요가 프로젝트에 마우스 오른쪽 버튼으로 클릭 => 속성 => 자바 빌드 경로.

라이브러리 추가 버튼을 클릭, 당신은 Junit4를 선택할 수 있습니다.

 

 

此时test包中的TestCookieFilter类会报CookieFilter编译异常,这是因为缺少CookieFilter这个类导致,经过一番查找总算找到了CookieFilter源码如下所示:

/*

* Licensed to the Apache Software Foundation (ASF) under one or more

* contributor license agreements. See the NOTICE file distributed with

* this work for additional information regarding copyright ownership.

* The ASF licenses this file to You under the Apache License, Version 2.0

* (the "License"); you may not use this file except in compliance with

* the License. You may obtain a copy of the License at

*

* http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable law or agreed to in writing, software

* distributed under the License is distributed on an "AS IS" BASIS,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and

* limitations under the License.

*/

package util;

 

import java.util.Locale;

import java.util.StringTokenizer;

 

/**

* Processes a cookie header and attempts to obfuscate any cookie values that

* represent session IDs from other web applications. Since session cookie names

* are configurable, as are session ID lengths, this filter is not expected to

* be 100% effective.

*

* It is required that the examples web application is removed in security

* conscious environments as documented in the Security How-To. This filter is

* intended to reduce the impact of failing to follow that advice. A failure by

* this filter to obfuscate a session ID or similar value is not a security

* vulnerability. In such instances the vulnerability is the failure to remove

* the examples web application.

*/

public class CookieFilter {

 

private static final String OBFUSCATED = "[obfuscated]";

 

private CookieFilter() {

// Hide default constructor

}

 

public static String filter(String cookieHeader, String sessionId) {

 

StringBuilder sb = new StringBuilder(cookieHeader.length());

 

// Cookie name value pairs are ';' separated.

// Session IDs don't use ; in the value so don't worry about quoted

// values that contain ;

StringTokenizer st = new StringTokenizer(cookieHeader, ";");

 

boolean first = true;

while (st.hasMoreTokens()) {

if (first) {

first = false;

} else {

sb.append(';');

}

sb.append(filterNameValuePair(st.nextToken(), sessionId));

}

 

 

return sb.toString();

}

 

private static String filterNameValuePair(String input, String sessionId) {

int i = input.indexOf('=');

if (i == -1) {

return input;

}

String name = input.substring(0, i);

String value = input.substring(i + 1, input.length());

 

return name + "=" + filter(name, value, sessionId);

}

 

public static String filter(String cookieName, String cookieValue, String sessionId) {

if (cookieName.toLowerCase(Locale.ENGLISH).contains("jsessionid") &&

(sessionId == null || !cookieValue.contains(sessionId))) {

cookieValue = OBFUSCATED;

}

 

return cookieValue;

}

}

 

此时仍有部分error,但不影响调试

设置Debug Configuration,设定程序入口,开始调试!

 

 


————————————————
原文链接:https://blog.csdn.net/xiongyouqiang/article/details/78941077

 

추천

출처www.cnblogs.com/tyyt/p/12032268.html