2013-04-02 3 views
1

Java JRE 혼합 코드 보안, JRE 1.6.0_19 및 으로 시작 2010 년 초에는 JDK/JRE 1.6을 사용하여 기본 Jar Java 애플릿이 구현, 빌드 및 배포되었습니다. .0_12; 주요 항아리와 제 3 자 항아리에 서명했다. 모든 것이 잘 작동한다. 주 jar Java 애플릿과 타사 jar는 JRE 1.6.0_12에서 JRE 1.6.0_18까지 잘 작동합니다.JRE 1.6.0_19로 시작하는 Java JRE 혼합 코드 보안

그러나 JRE 1.6.0_19로 시작하는 혼합 코드 보안이 도입되면 혼합 코드 보안이 해제되어 있지 않으면 주 Jar가 JRE 11.6.0_27에서 실행되지 않습니다.
우리는 JRE를 1.6.0_12에서 27로 변경하려고합니다.이 문제를 해결하려고합니다. 즉, 혼합 코드 보안이 사용 가능할 때 서명 된 기본 jar Java 애플릿과 서명 된 타사 jar를 시작할 수 있습니다.

Java Applet 소스 코드와 주요 항아리에서 사용하는 여러 타사 항아리가있는 기본 항아리가 있습니다.

JDK 1.6.0_27에서 keytool.exe를 사용하여 Java 용 개인 키/공개 키 쌍이있는 새 키 저장소를 만들었습니다 (예 : activation.jar, log4j-1.2.13.jar, ojdbc14.jar). 애플릿. JDK 1.6.0_27에서 jarsigner.exe를 사용하여 개인 항아리와 모든 제 3 자 항아리에 개인 키가 성공적으로 서명되었습니다. 각 jar에는 서명 파일 .SF와 서명 블록 파일 .DSA (Digital Signature Algorithm)가 있습니다. 나는 서명 된 항아리를 확인하기 위해 공개 키를 수출했다.

Java Applet 및 타사 jar는 웹 응용 프로그램의 webcontent/applet 디렉토리에 있습니다. 애플릿을 웹 응용 프로그램을 사용하여 실행하면 주 jar 및 타사 jar가 사용자 컴퓨터로 다운로드됩니다. 디지털 서명 부분이 잘 작동하므로 JRE 혼합 코드 보안이 사용 불가능할 때 Java 애플릿을 시작하고 성공적으로 실행할 수 있습니다. 이 기능을 사용하면 혼합 코드 보안이 해결되지 않습니다.

주 병을 신뢰할 수있는 라이브러리와 신뢰할 수있는 라이브러리로 배포하여 보았습니다. Mixed Code 보안이 활성화 된 두 상황 모두에서 주 Java 애플릿을 시작할 수 없으면 예외가 있지만 결과는 다릅니다.

Trusted-Only :: Mixed Code Enable 
......................... 
cache: Mark prevalidated: http://hostname:port/path/main.jar true tm=numbers cert=numbers 
security: http://hostname:port/path/main.jar is newly asserting Trusted-Only 
basic: Plugin2ClassLoader.getPermissions CeilingPolicy allPerms 
security: Validate the certificate chain using CertPath API 
security: The certificate hasnt been expired, no need to check timestamping info 
security: Cannot find jurisdiction list file 
security: The CRL support is disabled 
security: The OCSP support is disabled 
security: This OCSP End Entity validation is disabled 
security: Checking if certificate is in Deployment denied certificate store 
security: Checking if certificate is in Deployment permanent certificate store 
basic: Embedding dialogs not enabled in Configuration 
basic: Plugin2ClassLoader.getPermissions CeilingPolicy allPerms 
......................... 
......................... 
network: Cache entry not found [url: http://hostname:port/path/StatLib.jar, version:  null] 
network: Connecting http://hostname:port/path/StatLib.jar with proxy=DIRECT 
network: Connecting http://hostname:port/ with proxy=DIRECT 
network: Connecting http://hostname:port/path/StatLib.jar with cookie  "CheckboxChecked=Y; JSESSIONID=j_session_id" 
network: CleanupThread used 1 us 
network: Downloading resource: http://hostname:port/path/StatLib.jar 
Content-Length: 62,219 
Content-Encoding: null 
network: Wrote URL http://hostname:port/path/StatLib.jar to File C:\path\LocalLow\Sun\Java\Deployment\cache\6.0\24\167b0298-1365f142-temp 
security: Trusted libraries list file not found 
cache: Create from verifier: JarSigningData{hasOnlySignedEntries=true, hasSingleCodeSource=true, hasMissingSignedEntries=false} 
cache: Adding MemoryCache entry: http://hostname:port/path/StatLib.jar 
basic: Plugin2ClassLoader.isTrustedByPolicy called 
basic: Plugin2ClassLoader.isTrustedByPolicy returns false 
security: resource name "com/name/statistics/lib/I_Dispatch.class" in  http://hostname:port/path/StatLib.jar : java.lang.SecurityException: Trusted-Only loader attempted to load sandboxed resource from http://hostname:port/path/StatLib.jar 
04/01/2013 16:58:41,588 - [FATAL Thread-15 com.lfg.name.JavaObjectName.init(JavaName.java:193)] - Error in Method() java.lang.SecurityException: Trusted-Only loader attempted to load sandboxed resource from http://hostname:port/path/StatLib.jar 
at com.sun.deploy.security.CPCallbackHandler$ParentCallback.check(Unknown Source) 
at com.sun.deploy.security.CPCallbackHandler$ParentCallback.access$1500(Unknown Source) 
at com.sun.deploy.security.CPCallbackHandler$ChildElement.checkResource(Unknown Source) 
at com.sun.deploy.security.DeployURLClassPath$JarLoader.checkResource(Unknown Source) 
at com.sun.deploy.security.DeployURLClassPath$JarLoader.getResource(Unknown Source) 
at com.sun.deploy.security.DeployURLClassPath$JarLoader.getResource(Unknown Source) 
at com.sun.deploy.security.DeployURLClassPath.getResource(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source) 
at java.security.AccessController.doPrivileged(Native Method) 
at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source) 
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) 
at java.lang.ClassLoader.loadClass(Unknown Source) 
at java.lang.ClassLoader.defineClass1(Native Method) 
at java.lang.ClassLoader.defineClass(Unknown Source) 
at java.security.SecureClassLoader.defineClass(Unknown Source) 
at java.net.URLClassLoader.defineClass(Unknown Source) 
at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
at java.lang.reflect.Method.invoke(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader.defineClassHelper(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader.access$100(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source) 
at java.security.AccessController.doPrivileged(Native Method) 
at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source) 
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) 
at java.lang.ClassLoader.loadClass(Unknown Source) 
at java.lang.Class.forName0(Native Method) 
at java.lang.Class.forName(Unknown Source) 
.... Java Applet is calling and loading a class in a third party jar that I signed but for some reason is been treated as unsigned .... 
....................... 
network: Cache entry not found [url: http://hostname:port/path/ojdbc14.jar, version: null] 
network: Connecting http://hostname:port/path/ojdbc14.jar with proxy=DIRECT 
network: Connecting http://hostname:port/ with proxy=DIRECT 
network: Connecting http://hostname:port/path/ojdbc14.jar with cookie "CheckboxChecked=Y; JSESSIONID=j_session_id" 
network: CleanupThread used 1 us 
network: Downloading resource: http://hostname:port/path/ojdbc14.jar 
Content-Length: 1,448,790 
Content-Encoding: null 
network: Wrote URL http://hostname:port/path/ojdbc14.jar to File C:\path\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\534fe7f3-21a4d4ae-temp 
security: Trusted libraries list file not found 
cache: Create from verifier: JarSigningData{hasOnlySignedEntries=true, hasSingleCodeSource=true, hasMissingSignedEntries=false} 
network: CleanupThread used 1 us 
cache: Adding MemoryCache entry: http://hostname:port/path/ojdbc14.jar 
basic: Plugin2ClassLoader.isTrustedByPolicy called 
basic: Plugin2ClassLoader.isTrustedByPolicy returns false 
security: resource name "oracle/jdbc/driver/OracleDriver.class" in http://hostname:port/path/ojdbc14.jar : java.lang.SecurityException: Trusted-Only loader attempted to load sandboxed resource from http://hostname:port/path/ojdbc14.jar 
java.lang.SecurityException: Trusted-Only loader attempted to load sandboxed resource from http://hostname:port/path/ojdbc14.jar 
at com.sun.deploy.security.CPCallbackHandler$ParentCallback.check(Unknown Source) 
at com.sun.deploy.security.CPCallbackHandler$ParentCallback.access$1500(Unknown Source) 
at com.sun.deploy.security.CPCallbackHandler$ChildElement.checkResource(Unknown Source) 
at com.sun.deploy.security.DeployURLClassPath$JarLoader.checkResource(Unknown Source) 
at com.sun.deploy.security.DeployURLClassPath$JarLoader.getResource(Unknown Source) 
at com.sun.deploy.security.DeployURLClassPath$JarLoader.getResource(Unknown Source) 
at com.sun.deploy.security.DeployURLClassPath.getResource(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source) 
at java.security.AccessController.doPrivileged(Native Method) 
at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source) 
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) 
at java.lang.ClassLoader.loadClass(Unknown Source) 
..... java applet is loaded a java class in a third party jar that was signed, but is been treated as untrusted..... 

Trusted-Library :: Mixed Code Enable 
.............................. 
cache: Mark prevalidated: http://hostname:port/path/main.jar true tm=numbers cert=numbers 
basic: Plugin2ClassLoader.getPermissions CeilingPolicy allPerms 
security: Validate the certificate chain using CertPath API 
security: The certificate hasnt been expired, no need to check timestamping info 
security: Cannot find jurisdiction list file 
security: The CRL support is disabled 
security: The OCSP support is disabled 
security: This OCSP End Entity validation is disabled 
security: Checking if certificate is in Deployment denied certificate store 
security: Checking if certificate is in Deployment permanent certificate store 
basic: Embedding dialogs not enabled in Configuration 
basic: exception: java.lang.NoClassDefFoundError: org/apache/log4j/Logger. 
java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/apache/log4j/Logger 
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.instantiateApplet(Unknown Source) 
at sun.plugin2.applet.Plugin2Manager.initAppletAdapter(Unknown Source) 
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) 
at java.lang.Thread.run(Unknown Source) 
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Logger 
at com.path.MainClassApplet.init(MainClassApplet.java:line_number) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
at java.lang.reflect.Constructor.newInstance(Unknown Source) 
at java.lang.Class.newInstance0(Unknown Source) 
at java.lang.Class.newInstance(Unknown Source) 
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter$1.run(Unknown Source) 
at java.awt.event.InvocationEvent.dispatch(Unknown Source) 
at java.awt.EventQueue.dispatchEventImpl(Unknown Source) 
at java.awt.EventQueue.access$200(Unknown Source) 
at java.awt.EventQueue$3.run(Unknown Source) 
at java.awt.EventQueue$3.run(Unknown Source) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) 
at java.awt.EventQueue$4.run(Unknown Source) 
at java.awt.EventQueue$4.run(Unknown Source) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) 
at java.awt.EventQueue.dispatchEvent(Unknown Source) 
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) 
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) 
at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
at java.awt.EventDispatchThread.run(Unknown Source) 
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger 
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) 
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) 
at java.lang.ClassLoader.loadClass(Unknown Source) 
... 27 more 
Ignored exception: java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/apache/log4j/Logger 
basic: Dialog type is not candidate for embedding 
basic: Removed progress listener: [email protected] 
security: Reset deny session certificate store 

주요 항아리 애플릿 (리치 인터넷 애플리케이션)은 HTML 태그와 JavaServer 페이지 파일 (HTML 페이지)에 자바 스크립트 코드를 사용하여 호출입니다.

JavaScript 코드는 부호없는 코드처럼 취급됩니다. 서명 된 애플릿이 HTML 페이지의 JavaScript 코드에서 액세스되면 서명 된 애플릿은 보안 샌드 박스 내에서 실행됩니다. 이것은 서명 된 애플릿이 기본적으로 서명되지 않은 애플릿처럼 작동 함을 의미합니다.

배포 Tookit (deployJava.js)에서 JNLP를 사용하여 애플릿을 배포해야하는지 또는 기본 JAR 파일의 매니페스트 파일에있는 클래스 JAR 파일의 클래스 경로에 클래스를 추가해야하는지에 대해 논의 중입니다. 그 매니페스트는 애플릿의 목적을위한 유틸리티로 사용되는 다른 JAR 파일 (또는 여러 개의 다른 JAR 파일)을 참조합니다.

이 혼합형 코드 문제를 해결하는 방법에 대한 아이디어가 있으십니까?

감사합니다.

+0

애플릿의 jar manifest.mf 파일에있는 모든 서명 된 타사 jar 파일을 Class-Path 속성과 함께 추가하고 .JSP 페이지의 모든 아카이브에 태그를 추가하여이 문제를 해결했습니다. 애플릿 jar가 나열되고 마지막으로로드됩니다. –

답변

0

최근 JRE의 문제인지 확인할 수 있습니다. JS에서 Java로 호출하면 "혼합 코드 경고"가 발생합니다. 아무리 당신이 서명하거나 어떤 도서관에 포함 시키든 안하든. 위의 주석은 사실이 아니거나 더 이상 사실이 아닙니다 (최신 JRE 업그레이드 후, 나는 1.7.0_21로 작업 중입니다).

: 우리는 이런 종류의 문제에 대한에 제공된 솔루션은 다음과 같이 애플릿에서 폴링 것 commad 큐를 구현하는 것입니다, 그래서

그러나 다행히도 여전히 자바에서 호출하도록 허용 문제없이 자바 스크립트를 할 1) 예를 들어, "요청 객체"의 방법을 애플릿 각 호출을 래핑하고 큐에 넣어 :

var jobQueue = []; 

function hello(message) { 
    request = { 
    cmd:"hello", 
    arg:"Jack", 
    callback:function(result) { 
     alert("I'm saying "+result); 
    } 
    } 
    jobQueue.push(request); 
} 

2)하는 방법을 만들기 애플릿에서 호출 할 수있는 작업 얻을 :

function fetchJob(){ 
    if (jobQueue.length>0) { 
    return jobQueue.shift(); 
    } 
} 

3) 애플릿이 시작될 때마다 X 밀리 초마다 fetchJob 함수를 호출하는 스레드 또는 타이머를 생성합니다. 이 함수가 null이 아닌 요청을 반환하면 애플릿이 실행될 수 있습니다. 요청은 결과를 반환하기 위해 호출 될 콜백조차도 전달할 수 있습니다 (위 예제처럼).

그게 전부입니다. 그러나주의 : 콜백을 사용하여 결과를 반환하면 원시 객체와 다른 것을 반환하지 않도록주의하십시오. 그렇지 않으면 혼합 코드 경고가 다시 발생합니다. 문자열 배열도 작동하지 않습니다. 보다 복잡한 결과를 생성해야하는 경우 liveconnect API를 사용하여 javascript에 콜백하고 Java 애플릿에서 원시 JS 객체를 만든 다음이를 사용하여 콜백을 호출해야합니다.

행운을 빌어 요!

+0

Varitibolius : 정확합니다. JRE 1.7.0_21 및 JRE 1.7.0_45와 같은 최신 버전에서는 작동하지 않습니다. 나는 당신이 "명령 대기열"로 제안한 것을 시도 할 것입니다. 감사! –