게시중인 "예외"는 실제로 두 가지 항목, 즉 (1) 로그 메시지 및 (2) 실제 예외입니다. 이것들은 서로 다른 항목이지만, 여전히 동일한 근본적인 문제에서 기인합니다.
짧은 대답 : 앱을 초기화 할 때 보안 구성 시스템 속성을 설정하는 것을 잊어 버리고 있습니다. 그것은 모양은 다음과 같습니다 org.you.yourapp.YourAppSecurityConfiguration
당신이 그것을 쓸 것이다 클래스의 이름입니다
System.setProperty("org.owasp.esapi.SecurityConfiguration",
"org.you.yourapp.YourAppSecurityConfiguration");
는 SecurityConfiguration
을 구현합니다. 다음 ESAPI
코드가 실행될 때,이 시스템 속성을 설정하는 데 실패하기 때문에 :
private static String securityConfigurationImplName =
System.getProperty("org.owasp.esapi.SecurityConfiguration",
"org.owasp.esapi.reference.DefaultSecurityConfiguration");
을 당신이 속성을 설정하지 그 이후 ..., ESAPI는 당신을위한 DefaultSecurityConfiguration
을 선택하는 것입니다.
이 DefaultSecurityConfiguration
는 ESAPI의 내부 로깅 시스템을 초기화 간다
은, 다음의 메소드가 호출됩니다 :
protected String getESAPIProperty(String key, String def) {
String value = properties.getProperty(key);
if (value == null) {
logSpecial("SecurityConfiguration for " + key + " not found in ESAPI.properties. Using default: " + def, null);
return def;
}
return value;
}
은 여기을 찾고 속성은 Logger.LogEncodingRequired
라는 부울입니다. ESAPI.properties에서 찾을 수 없습니다 Logger.LogEncodingRequired에 대한
SecurityConfiguration : 첫 번째 문제의 처리합니다
boolean logEncodingRequired = true; // or false, your choice
System.setProperty("Logger.LogEncodingRequired", logEncodingRequired);
:이 첫 번째 메시지가 사라하려는 경우, 당신은 뭔가를해야합니다. 기본값 : false 사용
두 번째 문제는 DefaultSecurityConfiguration
을 선택한 ESAPI의 결과이기도합니다. 이 기본 구성에는 FileBasedAuthenticator
의 인스턴스를 반환하는 authenticator()
메서드가 있습니다. 그리고 javadoc 링크에 설명되어 있듯이 런타임 클래스 경로에 사용자에 관한 일련의 모든 정보가 포함 된 users.txt
파일이 있어야합니다.
java.lang.ClassCastException: org.owasp.esapi.reference.DefaultUser cannot be cast to com.bean.MyUserClass
: 그리고, 물론, FileBasedAuthenticator
는 (실제 예외 인) 2 문제를 얻고있는 이유 DefaultUser
의 인스턴스를 반환합니다.
당신이 캐스팅 할 수 있기 때문에 DefaultUser
자신의 MyUser
클래스 (다시 FileBasedAuthenticator
에서 통과).
혼동? 정말 그렇게 나쁘지 않습니다. 그냥 자신의 SecurityConfiguration
을 구현하고 시스템 속성으로 설정하면 모든 설정됩니다. HTH.
이 문제가 계속 발생합니까? – avgvstvs