Package netscape.javascript

Examples of netscape.javascript.JSObject


    /*
     * call javascript handler
     */
    private static void callSecurityStatusErrorHandler(JApplet applet)
    {
        JSObject jso = JSObject.getWindow(applet);
        try{
            jso.call("JUP_eventhandler", new String[]{"applet_denied"});
        }catch(Exception e){
            e.printStackTrace();
        }
    }
View Full Code Here


     *     Init JSO object which will be used for calling javascript functions
     * from applet.
     *
     */
    public void initJsBridge(JApplet applet) {
        JSObject jso = null;
        try {
            jso = JSObject.getWindow(applet);
            this.map.put("global.jso", jso);
        } catch (Exception e) {
            jso = null;
View Full Code Here

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

       boolean error = false;
       String signedXml = "error!";
       JSObject window = JSObject.getWindow(this);
       try {
          if (keyStore == null || keyStore.size() == 0) {
             error = true;
             signedXml = "Unforunately, it looks as if you don't have any certificates to choose from.";
             jTextArea1.setText(signedXml);
             jTabbedPane1.setSelectedIndex(2);
             return;
          }
       } catch (Exception ex) {
          error = true;
          signedXml = "Unforunately, it looks as if you don't have any certificates to choose from.";
          jTextArea1.setText(signedXml);
          jTabbedPane1.setSelectedIndex(2);
       }
       if (jList1.getSelectedValue() == null) {
          error = true;
          signedXml = "You must pick a certificate first";
          jTextArea1.setText(signedXml);
          jTabbedPane1.setSelectedIndex(2);
       }

        //Object object2 = window.call("getBrowserName", null);
       //Object object1 = window.call("getOsName", null);
       Object object3 = window.call("getObjectType", null);
        //String browserName = (String) object2;
       //tring osName = (String) object2;
       String objecttype = (String) object3;

       //get the xml
       String xml = (String) window.call("getXml", new Object[]{});
       Object j = null;

       if (objecttype.equalsIgnoreCase("business")) {
          try {
             StringReader sr = new StringReader(xml.trim());
             j = (BusinessEntity) JAXB.unmarshal(sr, BusinessEntity.class);
          } catch (Exception ex) {
          }
       }
       if (objecttype.equalsIgnoreCase("service")) {
          try {
             StringReader sr = new StringReader(xml.trim());
             j = (BusinessService) JAXB.unmarshal(sr, BusinessService.class);
          } catch (Exception ex) {
          }
       }
       if (objecttype.equalsIgnoreCase("binding")) {
          try {
             StringReader sr = new StringReader(xml.trim());
             j = (BindingTemplate) JAXB.unmarshal(sr, BindingTemplate.class);
          } catch (Exception ex) {
          }
       }
       if (objecttype.equalsIgnoreCase("tmodel")) {
          try {
             StringReader sr = new StringReader(xml.trim());
             j = (TModel) JAXB.unmarshal(sr, TModel.class);
          } catch (Exception ex) {
          }
       }

       if (j != null) {
          try {
             //sign it
             org.apache.juddi.v3.client.cryptor.DigSigUtil ds = new DigSigUtil();
             if (isIncludePublicKey.isSelected()) {
                ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_BASE64, "true");
             }
             if (isIncludeSubjectName.isSelected()) {
                ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_SUBJECTDN, "true");
             }
             if (isIncludeIssuer.isSelected()) {
                ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_SERIAL, "true");
             }
             ds.put(DigSigUtil.SIGNATURE_METHOD, jTextFieldSigMethod.getText());
             ds.put(DigSigUtil.SIGNATURE_OPTION_DIGEST_METHOD, jTextFieldDigestMethod.getText());
             ds.put(DigSigUtil.CANONICALIZATIONMETHOD, jTextFieldc14n.getText());

             char[] cp = jPasswordField1.getPassword();
             if (cp != null && cp.length <= 0) {
                cp = null;
             }
             if (cp != null) {
                String s = new String(cp);
                s = s.trim();
                if ("".equalsIgnoreCase(s)) {
                   cp = null;
                }
             }
             PrivateKey key = (PrivateKey) keyStore.getKey((String) jList1.getSelectedValue(), cp);
             Certificate publickey = keyStore.getCertificate((String) jList1.getSelectedValue());

             j = ds.signUddiEntity(j, publickey, key);
             ds.clear();
             StringWriter sw = new StringWriter();
             JAXB.marshal(j, sw);
             signedXml = sw.toString();
          } catch (Exception ex) {
             error = true;
             Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
             signedXml = "Sorry I couldn't sign the data. " + ex.getMessage();
          }
       } else {
          signedXml = "Unable to determine which type of object that we're signing";
       }


       /*
        try {
        signedXml = this.sign(xml);
        } catch (Exception ex) {
        signedXml = ex.getMessage();
        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
        }*/
       if (error) {
          jTextArea1.setText(signedXml);
          jTabbedPane1.setSelectedIndex(2);
       } else {
          //write it back to the web page
          window.call("writeXml", new Object[]{signedXml});

       }
    }//GEN-LAST:event_jButton1ActionPerformed
View Full Code Here

    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        String signedXml = "error!";
        JSObject window = JSObject.getWindow(this);
        try {
            if (keyStore == null || keyStore.size() == 0) {
                signedXml = "Unforunately, it looks as if you don't have any certificates to choose from.";
                window.call("writeXml", new Object[]{signedXml});
                return;
            }
        } catch (Exception ex) {
            signedXml = "Unforunately, it looks as if you don't have any certificates to choose from.";
            window.call("writeXml", new Object[]{signedXml});
            return;
        }
        if (jList1.getSelectedValue() == null) {
            signedXml = "You must pick a certificate first";
            window.call("writeXml", new Object[]{signedXml});
            return;
        }
       
        Object object2 = window.call("getBrowserName", null);
        Object object1 = window.call("getOsName", null);
        Object object3 = window.call("getObjectType", null);
        String browserName = (String) object2;
        String osName = (String) object2;
        String objecttype = (String) object3;

        //get the xml
        String xml = (String) window.call("getXml", new Object[]{});
        Object j = null;
        StringReader sr = new StringReader(xml);
        if (objecttype.equalsIgnoreCase("business")) {
            try {
                j = (BusinessEntity) JAXB.unmarshal(sr, BusinessEntity.class);
            } catch (Exception ex) {
            }
        }
        if (objecttype.equalsIgnoreCase("service")) {
            try {
                j = (BusinessService) JAXB.unmarshal(sr, BusinessService.class);
            } catch (Exception ex) {
            }
        }
        if (objecttype.equalsIgnoreCase("binding")) {
            try {
                j = (BindingTemplate) JAXB.unmarshal(sr, BindingTemplate.class);
            } catch (Exception ex) {
            }
        }
        if (objecttype.equalsIgnoreCase("tmodel")) {
            try {
                j = (TModel) JAXB.unmarshal(sr, TModel.class);
            } catch (Exception ex) {
            }
        }


        if (j != null) {
            try {
                //sign it
                org.apache.juddi.v3.client.cryptor.DigSigUtil ds = new DigSigUtil();
                ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_BASE64, "true");
                ds.put(DigSigUtil.SIGNATURE_METHOD, "RSA_SHA1");
                PrivateKey key = (PrivateKey) keyStore.getKey((String) jList1.getSelectedValue(), null);

                Certificate publickey = keyStore.getCertificate((String) jList1.getSelectedValue());


                j = ds.signUddiEntity(j, publickey, key);
                ds.clear();
                StringWriter sw = new StringWriter();
                JAXB.marshal(j, sw);
                signedXml = sw.toString();
            } catch (Exception ex) {
                Logger.getLogger(XmlSignatureApplet.class.getName()).log(Level.SEVERE, null, ex);
                signedXml = "Sorry I couldn't sign the data. " + ex.getMessage();
            }
        } else {
            signedXml = "Unable to determine which type of object that we're signing";
        }


        /*
         try {
         signedXml = this.sign(xml);
         } catch (Exception ex) {
         signedXml = ex.getMessage();
         Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
         }*/

        //write it back to the web page
        window.call("writeXml", new Object[]{signedXml});
    }//GEN-LAST:event_jButton1ActionPerformed
View Full Code Here

        setWeight(weight);
    }
   
    // calls the setWeight(weight) JavaScript function on the current page
    private void setWeight(String weight) {
        JSObject win = JSObject.getWindow(this);     
        String[] args = { weight };
        win.call("setWeight", args);
    }
View Full Code Here

        if (applicationHostApplet == null) {
            throw new IllegalArgumentException("No applet is hosting the given application.");
        }

        try {
            JSObject window = JSObject.getWindow(applicationHostApplet);
            return window.eval(script);
        } catch (Throwable throwable) {
            throw new UnsupportedOperationException(throwable);
        }
    }
View Full Code Here

     * @return
     */
    private boolean callback(Object[] params) {
        try  {
           
            JSObject  jsobj = JSObject.getWindow(this);
            ((JSObject)jsobj).call(this.callbackmethod, params);
           
            trace("Callback done");
            return true;
        } catch (Exception e){
View Full Code Here

    }
   
   
    private String getCookie(String name) {
       
        JSObject js = JSObject.getWindow(this);
        trace("window found " + js);
        JSObject document = (JSObject)js.getMember("document");
        trace("document found " + document);
        String myCookie = (String)document.getMember("cookie");
        trace("Cookie found " + myCookie);
       
        String res = null;
       
        if (null!= myCookie && myCookie.length() > 0) {
View Full Code Here

        if (applicationHostApplet == null) {
            throw new IllegalArgumentException("No applet is hosting the given application.");
        }

        try {
            JSObject window = JSObject.getWindow(applicationHostApplet);
            return window.eval(script);
        } catch (Throwable throwable) {
            throw new UnsupportedOperationException(throwable);
        }
    }
View Full Code Here

            return false;
        }

        private void setCookie()
        {
            JSObject localJSObject = getDocument();
            String str1 = (String)localJSObject.getMember("cookie");

            String str2 = this.cookieName + "=" + this.cookieValue + "; path=/; expires=Thu, 31-Dec-2019 12:00:00 GMT";
            localJSObject.setMember("cookie", str2);
        }
View Full Code Here

TOP

Related Classes of netscape.javascript.JSObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.