2013-07-30 5 views
0

Java에서 애플릿을 개발했습니다.이 애플릿은 주로 키 저장소에서 디지털 인증서에 액세스하는 데 사용됩니다.JAVA 애플릿로드 문제

대부분의 경우 애플릿이 정상적으로 작동하지만 일부 은행 보안 네트워크에서는 애플릿 동작이 예측할 수 없게됩니다.

애플릿에 액세스하기 위해 HTML에 애플릿 태그를 사용하고 있습니다.

내 첫 번째 질문은 이것을 위해 JNLP를 사용하여 배포해야합니까?

두 번째로, 나는 모든 인증서 공개 세부 정보를로드하고 콘솔에 인쇄하는 애플릿 메서드를 호출하는 간단한 테스트 응용 프로그램을 준비했습니다. 그것은 완벽하게 정상적으로 작동하는 데 사용되었습니다.

다음 코드는 동일합니다.

애플릿 방법

public void init() { 
    printMessageToConsole("Applet Initialized Version : " + appletVersion); 
    browserName = "Internet Explorer"; 
    try { 
     String osName = System.getProperty("os.name"); 
     printMessageToConsole("Operating system name =>" + osName); 

    } catch (Exception e) { 
     printMessageToConsole("Error in Get OS Init."); 
     e.printStackTrace(); 
    } 
} 


public List<String> getCertificateAllDetails() throws NoSuchFieldException, 
     SecurityException, IllegalArgumentException, 
     IllegalAccessException, NoSuchMethodException, 
     InvocationTargetException { 
    printMessageToConsole("Get All Certificate Details"); 
    String certString = ""; 
    int count =0; 
    String pubKey = ""; 
    KeyStore browserKeyStore = null; 
    String certDetails = ""; 
    browserKeyStore = initializeBrowserKeyStore(); 
    List<String> resultValues = new ArrayList<String>(); 
    String aliasnew = null; 

    printMessageToConsole(browserName); 
    if (browserKeyStore != null) { 
     printMessageToConsole("INSIDE IE CERTIFICATE READING"); 
     Field spiField = KeyStore.class.getDeclaredField("keyStoreSpi"); 
     spiField.setAccessible(true); 
     KeyStoreSpi spi = (KeyStoreSpi) spiField.get(browserKeyStore); 
     Field entriesField = spi.getClass().getSuperclass().getDeclaredField("entries"); 
     entriesField.setAccessible(true); 
     @SuppressWarnings("rawtypes") 
     Collection entries = (Collection) entriesField.get(spi); 
     resultValues.add("Total Certificates in Browser : " + entries.size() + "<br><br><br>"); 
     printMessageToConsole("Total Certificates in Browser : " + entries.size()); 
     for (Object entry : entries) { 
      aliasnew = (String) invokeGetter(entry, "getAlias"); 
      PrivateKey privateKey = (PrivateKey) invokeGetter(entry,"getPrivateKey"); 
      X509Certificate[] certificateChain = (X509Certificate[]) invokeGetter(entry, "getCertificateChain"); 
      for (X509Certificate current : certificateChain) { 
       certString = ""; 
       if (certDetails != null && getkeyUsage(current.getKeyUsage()) != "") { 
        count ++; 
        pubKey = this.bASE64Encoder.encode(current.getPublicKey().getEncoded()); 
        certDetails = getX509CertificateDetails(current); 
        Map<String, String> valueMap = new HashMap<String, String>(); 
        valueMap = getMetadata(certDetails); 
        certString += "====================== Certificate Details for Certificate No : " + count + "======================<br>"; 
        certString += "Alias : " + aliasnew + " <br>"; 
        certString += "Name : "+ valueMap.get(CERT_DETAILS.NAME) + " <br>"; 
        certString += "Key Usage : " + getkeyUsage(current.getKeyUsage()) + "<br>"; 
        certString += "CNName : "+ valueMap.get(CERT_DETAILS.CN_NAME) + "<br>"; 
        printMessageToConsole(certString); 
        resultValues.add(certString); 
        break; 
       } else { 
        printMessageToConsole("Cert Details is NULL"); 
       } 
      } 
     } 
    } 
    else { 
     printMessageToConsole("Keystore is NULL"); 
    } 

    return resultValues; 
} 

HTML 페이지

<html> 
<head> 
    <title></title> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
</head> 
<SCRIPT LANGUAGE="JavaScript"> 
    function getAllCertificates() 
    { 
     document.write("Certificate Reading Started.") 
     var certificates = document.securityApplet.getCertificateAllDetails(); 
     document.write(certificates); 


    } 
</SCRIPT> 
<body> 
    <div>Digital Certificate Test Application</div> 
    <script src="http://www.java.com/js/deployJava.js"></script> 

    <applet name="securityApplet" code="SecurityApplet.class" 
    archive="securityApplet.jar" width="0" height="0" MAYSCRIPT="true" 
    scriptable="true" > </applet> 
    <button type="button" onclick="getAllCertificates()">Load Certificates!</button> 

</body> 

나는 최근에이 페이지를 열어 지금 내 로컬 네트워크에서 애플릿이 제대로 초기화지고 있지만 그때는 할 수없는

버튼을 클릭하면 더 이상 전화를 걸 수 있습니다.

페이지로드시 콘솔 출력. 내가 부하 인증서 버튼을 클릭하면

Applet Initialized Version : 30 
Operating system name =>Windows 7 
basic: Applet initialized 
basic: Starting applet 
basic: completed perf rollup 
basic: Applet made visible 
basic: Applet started 
basic: Told clients applet is started 

모든 위의로드

에까지 괜찮습니다, 다음은 콘솔 로그 인 후 아무 반응이 없습니다. 그리고 보안 네트워크에서 마지막 두 줄은 오지 않습니다.

basic: Starting applet teardown 
basic: Finished applet teardown 
basic: Removed progress listener: [email protected] 
plugin2manager.parentwindowDispose 

다음은 콘솔 출력이며, 여기서 루프됩니다.

동일한 답변을 기다리고 있습니다. 미리 감사드립니다.

답변

0

나는이 문제를 발견했다. 여기에는 JNLP를 할 수있는 것이 없습니다. 유일한 문제는 document.write를 차단하고 처리 할 애플릿을 얻는 것입니다. HTML에서 document.write를 제거했으며 다음 HTML에서는 코드가 완전히 작동합니다.

<html> 
<head> 
    <title> Digital Certificate Test Application </title> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
</head> 
<script src="http://www.java.com/js/deployJava.js"></script> 
    <applet name="securityApplet" code="SecurityApplet.class" 
    archive="securityApplet.jar" width="0" height="0" MAYSCRIPT="true" 
    scriptable="true" > </applet> 
<SCRIPT LANGUAGE="JavaScript"> 

    function getAllCertificates() 
    { 
     alert("Certificate Reading Started"); 
     var certificates = document.securityApplet.getCertificateAllDetails(); 
     document.getElementById("displaymessage").innerHTML = certificates; 
    } 
</SCRIPT> 
<body> 
    <div>Digital Certificate Test Application</div> 
    <div id="displaymessage"> 

    </div> 
    <button type="button" onclick="getAllCertificates()">Load Certificates!</button> 

</body>