Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $JAVA_HOME/bin/keytool -genkeypair -keyalg RSA -keysize 2048 -alias mydomain -validity 1825
- $JAVA_HOME/bin/jarsigner -tsa http://timestamp.digicert.com -storepass password applet.jar mydomain
- #!/bin/bash
- #
- # Title-
- # mkJavaKey
- #
- # Function-
- # Create a new key using $JAVA_HOME/bin/keytool
- #
- # Usage-
- # mkJavaKey ## CYGWIN ONLY ##
- # (This is required when jarsigner complains about an expired key.)
- # NOTE: This *REMOVES* and *REPLACES* your existing .keystore file!
- #
- #######
- ##########################################################################
- # Environment check
- if [ -z "$JAVA_HOME" ] ; then
- . setupJAVA ## (This personal script sets JAVA_HOME)
- if [ -z "$JAVA_HOME" ] ; then
- echo "JAVA_HOME environment variable missing"
- exit 1
- fi
- fi
- if [ -z "$HOMEPATH" ] ; then
- echo "HOMEPATH environment variable missing"
- echo "Try export HOMEPATH=Usersmyname"
- exit 1
- fi
- home_path=`cygpath --path --unix C:$HOMEPATH`
- PGM=$JAVA_HOME/bin/keytool
- if [ ! -x "$PGM" ] ; then
- echo "$PGM not executable"
- exit 1
- fi
- ##########################################################################
- # Create a new .keystore
- set -x
- rm -Rf $home_path/.keystore
- $PGM -genkeypair -keyalg RSA -keysize 2048 -alias mydomain -validity 1825
- exit $?
- .PHONY: golfer.install
- golfer.install: test golfer
- : (Not relevant to discussion)
- cp -p $(OBJDIR)/usr/fne/golfer/Applet/applet.jar $(DEPLOYDIR)/webapps/golfer/.
- jarsigner -tsa http://timestamp.digicert.com -storepass password "$(shell cygpath --path --windows "$(DEPLOYDIR)/webapps/golfer/applet.jar")" mydomain
- : (Not relevant to discussion)
- //------------------------------------------------------------------------
- //
- // Title-
- // applet.js
- //
- // Purpose-
- // Common applet javascript.
- //
- // Last change date-
- // 2010/10/19
- //
- //------------------------------------------------------------------------
- var out; // Output document
- //------------------------------------------------------------------------
- // appHead
- //
- // Generate html header for application.
- //------------------------------------------------------------------------
- function appHead(title,cname,height,width)
- {
- var todoWindow= window.open('','','');
- out= todoWindow.document;
- out.write('<html>');
- out.write('<head><title>' + title + '</title></head>');
- out.write('<body>n');
- out.write('<applet code="' + cname + '.class"');
- out.write(' codebase="./"')
- out.write(' archive="applet.jar,jars/common.jar"');
- out.write(' width="' + width + '" height="' + height + '">n');
- }
- //------------------------------------------------------------------------
- // appParm
- //
- // Add parameter information
- //------------------------------------------------------------------------
- function appParm(name, value)
- {
- out.write(' <param-name="' + name + '" value="' + value + '"/>n');
- }
- //------------------------------------------------------------------------
- // appTail
- //
- // Generate html trailer information.
- //------------------------------------------------------------------------
- function appTail()
- {
- out.write('Your browser is completely ignoring the <APPLET> tag!n');
- out.write('</applet>');
- out.write('<form>');
- out.write('<input type="button" value="Done" onclick="window.close()">');
- out.write('</form>');
- out.write('</body>');
- out.write('</html>');
- out.close();
- out= null;
- }
- //------------------------------------------------------------------------
- // cardEvents
- //
- // Display scorecard for selected date.
- //------------------------------------------------------------------------
- function cardEvents(eventsID, obj)
- {
- if( obj.selectedIndex == 0 )
- {
- alert("No date selected");
- return;
- }
- appHead('Score card', 'EventsCard', '100%', '100%');
- appParm('events-nick', eventsID);
- appParm('events-date', obj[obj.selectedIndex].value);
- appTail();
- reset();
- }
- //------------------------------------------------------------------------
- //
- // Title-
- // applet.js
- //
- // Purpose-
- // Common applet javascript.
- //
- // Last change date-
- // 2017/03/15
- //
- //------------------------------------------------------------------------
- var out; // Output URL
- //------------------------------------------------------------------------
- // appHead
- //
- // Generate application URL header.
- //------------------------------------------------------------------------
- function appHead(title,cname,height,width)
- {
- out= cname + ',' + title;
- }
- //------------------------------------------------------------------------
- // appParm
- //
- // Generate html parameter information.
- //------------------------------------------------------------------------
- function appParm(name, value)
- {
- out= out + ',' + name + '=' + value;
- }
- //------------------------------------------------------------------------
- // appTail
- //
- // Generate html trailer information.
- //------------------------------------------------------------------------
- function appTail()
- {
- var specs= 'menubar=yes,toolbar=yes';
- window.open('Applet.jnlp?' + out, '_self', specs);
- }
- //------------------------------------------------------------------------
- // cardEvents
- //
- // Display scorecard for selected date.
- //------------------------------------------------------------------------
- function cardEvents(eventsID, obj)
- {
- // (UNCHANGED!)
- }
- //------------------------------------------------------------------------
- //
- // Method-
- // AppletServlet.doGet
- //
- // Purpose-
- // Called for each HTTP GET request.
- //
- //------------------------------------------------------------------------
- public void
- doGet( // Handle HTTP "GET" request
- HttpServletRequest req, // Request information
- HttpServletResponse res) // Response information
- throws ServletException, IOException
- {
- String q= req.getQueryString();
- if( debug ) log("doGet("+q+")");
- res.setContentType("text/html");
- query(req, res);
- }
- //------------------------------------------------------------------------
- //
- // Method-
- // AppletServlet.putError
- //
- // Purpose-
- // Generate error response.
- //
- //------------------------------------------------------------------------
- public void
- putError( // Generate error response
- PrintWriter out, // The response writer
- String msg) // The error message
- { out.println("<HTML>");
- out.println("<HEAD><TITLE>" + msg + "</TITLE></HEAD>");
- out.println("<BODY>");
- out.println("<H1 align="center">" + msg + "</H1>");
- out.println("</BODY>");
- out.println("</HTML>");
- }
- //------------------------------------------------------------------------
- //
- // Method-
- // AppletServlet.query
- //
- // Purpose-
- // Handle a query.
- //
- //------------------------------------------------------------------------
- protected void
- query( // Handle a query
- HttpServletRequest req, // Request information
- HttpServletResponse res) // Response information
- throws ServletException, IOException
- {
- String q= req.getQueryString();
- if( debug ) log("query("+q+")");
- PrintWriter out = res.getWriter();
- String BOGUS= "<br> Malformed request: query: '" + q + "'";
- //=====================================================================
- // Applet.jnlp?classname,title,parm=value,parm=value,...
- int index= q.indexOf(',');
- if( index < 0 || index == (q.length() - 1) )
- {
- putError(out, BOGUS);
- return;
- }
- String invoke= q.substring(0, index);
- q= q.substring(index+1);
- index= q.indexOf(',');
- if( index < 0 )
- index= q.length();
- String title= q.substring(0, index);
- title= java.net.URLDecoder.decode(title, "UTF-8");
- // Parameter extraction
- Vector<String> param= new Vector<String>();
- if( index < q.length() )
- {
- q= q.substring(index+1);
- for(;;)
- {
- index= q.indexOf(',');
- if( index < 0 )
- index= q.length();
- String s= q.substring(0, index);
- int x= s.indexOf('=');
- if( x < 0 )
- {
- putError(out, BOGUS);
- return;
- }
- param.add(s);
- if( index >= q.length() )
- break;
- q= q.substring(index+1);
- }
- }
- //---------------------------------------------------------------------
- // We now have enough information to generate the response
- //---------------------------------------------------------------------
- res.setContentType("application/x-java-jnlp-file");
- out.println("<?xml version='1.0' encoding='utf-8'?>");
- out.println("<jnlp spec='1.0+' codebase='http://localhost:8080/golfer'>");
- out.println(" <information>");
- out.println(" <title>" + title + "</title>");
- out.println(" <vendor>My Name</vendor>");
- out.println(" <description>" + title + "</description>");
- out.println(" </information>");
- out.println(" <security><all-permissions/></security>");
- out.println(" <resources>");
- out.println(" <j2se version='1.7+'/>");
- out.println(" <jar href='applet.jar'/>");
- out.println(" <jar href='jars/common.jar'/>");
- out.println(" </resources>");
- out.println(" <applet-desc main-class='" + invoke + "' name='" + title + "'" +
- " height='90%' width='98%'>");
- // Insert applet parameters
- for(int i= 0; i<param.size(); i++)
- {
- String s= param.elementAt(i);
- int x= s.indexOf('=');
- String n= s.substring(0,x);
- String v= s.substring(x+1);
- out.println(" <param name='" + n+ "' value='" + v + "'/>");
- }
- out.println(" </applet-desc>");
- out.println("</jnlp>");
- }
- <?xml version="1.0" encoding="ISO-8859-1"?>
- <!DOCTYPE web-app
- PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
- <web-app>
- <servlet>
- <servlet-name>Applet</servlet-name>
- <servlet-class>usr.fne.golfer.AppletServlet</servlet-class>
- <init-param>
- <param-name>property-path</param-name>
- <param-value>profile</param-value>
- </init-param>
- <init-param>
- <param-name>property-file</param-name>
- <param-value>golfer.pro</param-value>
- </init-param>
- <load-on-startup>30</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>Applet</servlet-name>
- <url-pattern>/Applet.jnlp</url-pattern>
- </servlet-mapping>
- : (Other Servlets unchanged)
- </web-app>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement