Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.26 KB | None | 0 0
  1. $JAVA_HOME/bin/keytool -genkeypair -keyalg RSA -keysize 2048 -alias mydomain -validity 1825
  2.  
  3. $JAVA_HOME/bin/jarsigner -tsa http://timestamp.digicert.com -storepass password applet.jar mydomain
  4.  
  5. #!/bin/bash
  6. #
  7. # Title-
  8. # mkJavaKey
  9. #
  10. # Function-
  11. # Create a new key using $JAVA_HOME/bin/keytool
  12. #
  13. # Usage-
  14. # mkJavaKey ## CYGWIN ONLY ##
  15. # (This is required when jarsigner complains about an expired key.)
  16. # NOTE: This *REMOVES* and *REPLACES* your existing .keystore file!
  17. #
  18. #######
  19.  
  20. ##########################################################################
  21. # Environment check
  22. if [ -z "$JAVA_HOME" ] ; then
  23. . setupJAVA ## (This personal script sets JAVA_HOME)
  24. if [ -z "$JAVA_HOME" ] ; then
  25. echo "JAVA_HOME environment variable missing"
  26. exit 1
  27. fi
  28. fi
  29.  
  30. if [ -z "$HOMEPATH" ] ; then
  31. echo "HOMEPATH environment variable missing"
  32. echo "Try export HOMEPATH=Usersmyname"
  33. exit 1
  34. fi
  35.  
  36. home_path=`cygpath --path --unix C:$HOMEPATH`
  37. PGM=$JAVA_HOME/bin/keytool
  38. if [ ! -x "$PGM" ] ; then
  39. echo "$PGM not executable"
  40. exit 1
  41. fi
  42.  
  43. ##########################################################################
  44. # Create a new .keystore
  45. set -x
  46. rm -Rf $home_path/.keystore
  47. $PGM -genkeypair -keyalg RSA -keysize 2048 -alias mydomain -validity 1825
  48. exit $?
  49.  
  50. .PHONY: golfer.install
  51. golfer.install: test golfer
  52. : (Not relevant to discussion)
  53. cp -p $(OBJDIR)/usr/fne/golfer/Applet/applet.jar $(DEPLOYDIR)/webapps/golfer/.
  54. jarsigner -tsa http://timestamp.digicert.com -storepass password "$(shell cygpath --path --windows "$(DEPLOYDIR)/webapps/golfer/applet.jar")" mydomain
  55. : (Not relevant to discussion)
  56.  
  57. //------------------------------------------------------------------------
  58. //
  59. // Title-
  60. // applet.js
  61. //
  62. // Purpose-
  63. // Common applet javascript.
  64. //
  65. // Last change date-
  66. // 2010/10/19
  67. //
  68. //------------------------------------------------------------------------
  69. var out; // Output document
  70.  
  71. //------------------------------------------------------------------------
  72. // appHead
  73. //
  74. // Generate html header for application.
  75. //------------------------------------------------------------------------
  76. function appHead(title,cname,height,width)
  77. {
  78. var todoWindow= window.open('','','');
  79. out= todoWindow.document;
  80. out.write('<html>');
  81. out.write('<head><title>' + title + '</title></head>');
  82. out.write('<body>n');
  83. out.write('<applet code="' + cname + '.class"');
  84. out.write(' codebase="./"')
  85. out.write(' archive="applet.jar,jars/common.jar"');
  86. out.write(' width="' + width + '" height="' + height + '">n');
  87. }
  88.  
  89. //------------------------------------------------------------------------
  90. // appParm
  91. //
  92. // Add parameter information
  93. //------------------------------------------------------------------------
  94. function appParm(name, value)
  95. {
  96. out.write(' <param-name="' + name + '" value="' + value + '"/>n');
  97. }
  98.  
  99. //------------------------------------------------------------------------
  100. // appTail
  101. //
  102. // Generate html trailer information.
  103. //------------------------------------------------------------------------
  104. function appTail()
  105. {
  106. out.write('Your browser is completely ignoring the <APPLET> tag!n');
  107. out.write('</applet>');
  108. out.write('<form>');
  109. out.write('<input type="button" value="Done" onclick="window.close()">');
  110. out.write('</form>');
  111. out.write('</body>');
  112. out.write('</html>');
  113. out.close();
  114. out= null;
  115. }
  116.  
  117. //------------------------------------------------------------------------
  118. // cardEvents
  119. //
  120. // Display scorecard for selected date.
  121. //------------------------------------------------------------------------
  122. function cardEvents(eventsID, obj)
  123. {
  124. if( obj.selectedIndex == 0 )
  125. {
  126. alert("No date selected");
  127. return;
  128. }
  129. appHead('Score card', 'EventsCard', '100%', '100%');
  130. appParm('events-nick', eventsID);
  131. appParm('events-date', obj[obj.selectedIndex].value);
  132. appTail();
  133. reset();
  134. }
  135.  
  136. //------------------------------------------------------------------------
  137. //
  138. // Title-
  139. // applet.js
  140. //
  141. // Purpose-
  142. // Common applet javascript.
  143. //
  144. // Last change date-
  145. // 2017/03/15
  146. //
  147. //------------------------------------------------------------------------
  148. var out; // Output URL
  149.  
  150. //------------------------------------------------------------------------
  151. // appHead
  152. //
  153. // Generate application URL header.
  154. //------------------------------------------------------------------------
  155. function appHead(title,cname,height,width)
  156. {
  157. out= cname + ',' + title;
  158. }
  159.  
  160. //------------------------------------------------------------------------
  161. // appParm
  162. //
  163. // Generate html parameter information.
  164. //------------------------------------------------------------------------
  165. function appParm(name, value)
  166. {
  167. out= out + ',' + name + '=' + value;
  168. }
  169.  
  170. //------------------------------------------------------------------------
  171. // appTail
  172. //
  173. // Generate html trailer information.
  174. //------------------------------------------------------------------------
  175. function appTail()
  176. {
  177. var specs= 'menubar=yes,toolbar=yes';
  178. window.open('Applet.jnlp?' + out, '_self', specs);
  179. }
  180.  
  181. //------------------------------------------------------------------------
  182. // cardEvents
  183. //
  184. // Display scorecard for selected date.
  185. //------------------------------------------------------------------------
  186. function cardEvents(eventsID, obj)
  187. {
  188. // (UNCHANGED!)
  189. }
  190.  
  191. //------------------------------------------------------------------------
  192. //
  193. // Method-
  194. // AppletServlet.doGet
  195. //
  196. // Purpose-
  197. // Called for each HTTP GET request.
  198. //
  199. //------------------------------------------------------------------------
  200. public void
  201. doGet( // Handle HTTP "GET" request
  202. HttpServletRequest req, // Request information
  203. HttpServletResponse res) // Response information
  204. throws ServletException, IOException
  205. {
  206. String q= req.getQueryString();
  207. if( debug ) log("doGet("+q+")");
  208.  
  209. res.setContentType("text/html");
  210.  
  211. query(req, res);
  212. }
  213.  
  214. //------------------------------------------------------------------------
  215. //
  216. // Method-
  217. // AppletServlet.putError
  218. //
  219. // Purpose-
  220. // Generate error response.
  221. //
  222. //------------------------------------------------------------------------
  223. public void
  224. putError( // Generate error response
  225. PrintWriter out, // The response writer
  226. String msg) // The error message
  227. { out.println("<HTML>");
  228. out.println("<HEAD><TITLE>" + msg + "</TITLE></HEAD>");
  229. out.println("<BODY>");
  230. out.println("<H1 align="center">" + msg + "</H1>");
  231. out.println("</BODY>");
  232. out.println("</HTML>");
  233. }
  234.  
  235. //------------------------------------------------------------------------
  236. //
  237. // Method-
  238. // AppletServlet.query
  239. //
  240. // Purpose-
  241. // Handle a query.
  242. //
  243. //------------------------------------------------------------------------
  244. protected void
  245. query( // Handle a query
  246. HttpServletRequest req, // Request information
  247. HttpServletResponse res) // Response information
  248. throws ServletException, IOException
  249. {
  250. String q= req.getQueryString();
  251. if( debug ) log("query("+q+")");
  252.  
  253. PrintWriter out = res.getWriter();
  254. String BOGUS= "<br> Malformed request: query: '" + q + "'";
  255.  
  256. //=====================================================================
  257. // Applet.jnlp?classname,title,parm=value,parm=value,...
  258. int index= q.indexOf(',');
  259. if( index < 0 || index == (q.length() - 1) )
  260. {
  261. putError(out, BOGUS);
  262. return;
  263. }
  264. String invoke= q.substring(0, index);
  265.  
  266. q= q.substring(index+1);
  267. index= q.indexOf(',');
  268. if( index < 0 )
  269. index= q.length();
  270. String title= q.substring(0, index);
  271. title= java.net.URLDecoder.decode(title, "UTF-8");
  272.  
  273. // Parameter extraction
  274. Vector<String> param= new Vector<String>();
  275. if( index < q.length() )
  276. {
  277. q= q.substring(index+1);
  278. for(;;)
  279. {
  280. index= q.indexOf(',');
  281. if( index < 0 )
  282. index= q.length();
  283.  
  284. String s= q.substring(0, index);
  285. int x= s.indexOf('=');
  286. if( x < 0 )
  287. {
  288. putError(out, BOGUS);
  289. return;
  290. }
  291.  
  292. param.add(s);
  293. if( index >= q.length() )
  294. break;
  295.  
  296. q= q.substring(index+1);
  297. }
  298. }
  299.  
  300. //---------------------------------------------------------------------
  301. // We now have enough information to generate the response
  302. //---------------------------------------------------------------------
  303. res.setContentType("application/x-java-jnlp-file");
  304. out.println("<?xml version='1.0' encoding='utf-8'?>");
  305. out.println("<jnlp spec='1.0+' codebase='http://localhost:8080/golfer'>");
  306. out.println(" <information>");
  307. out.println(" <title>" + title + "</title>");
  308. out.println(" <vendor>My Name</vendor>");
  309. out.println(" <description>" + title + "</description>");
  310. out.println(" </information>");
  311. out.println(" <security><all-permissions/></security>");
  312. out.println(" <resources>");
  313. out.println(" <j2se version='1.7+'/>");
  314. out.println(" <jar href='applet.jar'/>");
  315. out.println(" <jar href='jars/common.jar'/>");
  316. out.println(" </resources>");
  317. out.println(" <applet-desc main-class='" + invoke + "' name='" + title + "'" +
  318. " height='90%' width='98%'>");
  319.  
  320. // Insert applet parameters
  321. for(int i= 0; i<param.size(); i++)
  322. {
  323. String s= param.elementAt(i);
  324. int x= s.indexOf('=');
  325. String n= s.substring(0,x);
  326. String v= s.substring(x+1);
  327. out.println(" <param name='" + n+ "' value='" + v + "'/>");
  328. }
  329. out.println(" </applet-desc>");
  330. out.println("</jnlp>");
  331. }
  332.  
  333. <?xml version="1.0" encoding="ISO-8859-1"?>
  334. <!DOCTYPE web-app
  335. PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
  336. "http://java.sun.com/dtd/web-app_2_3.dtd">
  337. <web-app>
  338. <servlet>
  339. <servlet-name>Applet</servlet-name>
  340. <servlet-class>usr.fne.golfer.AppletServlet</servlet-class>
  341. <init-param>
  342. <param-name>property-path</param-name>
  343. <param-value>profile</param-value>
  344. </init-param>
  345. <init-param>
  346. <param-name>property-file</param-name>
  347. <param-value>golfer.pro</param-value>
  348. </init-param>
  349. <load-on-startup>30</load-on-startup>
  350. </servlet>
  351.  
  352. <servlet-mapping>
  353. <servlet-name>Applet</servlet-name>
  354. <url-pattern>/Applet.jnlp</url-pattern>
  355. </servlet-mapping>
  356.  
  357. : (Other Servlets unchanged)
  358. </web-app>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement