¿ìËÙÒµÎñͨµÀ

»ùÓÚJava 2ÔËÐÐʱ°²È«Ä£Ð͵ÄÏß³ÌЭ×÷ - ±à³ÌÈëÃÅÍø

×÷Õß ØýÃû¼¼Êõ À´Ô´ NET±à³Ì ä¯ÀÀ ·¢²¼Ê±¼ä 2012-06-25

ʾÀý

ÎÒÃǵÄʾÀýºÜ¼òµ¥£º¿Í»§¶Ëµ÷Óà LogService ÌṩµÄ API£¬°Ñ Message дÈëµ½´ÅÅÌÎļþ¡£

Çåµ¥ 1. ¿Í»§¶Ë³ÌÐò

package¡¡sample.permtest.client; …… public¡¡class¡¡Client¡¡{ …… public¡¡static¡¡void¡¡main(String[]¡¡args)¡¡{ //¹¹ÔìÏûÏ¢ÈÕÖ¾£¬Ê¹ÓÃLogService½«ÆäдÈëc:\\paper\\client\\out.tmpÎļþ¡£ Message¡¡message¡¡=¡¡new¡¡Message("c:\\paper\\client\\out.tmp", "Hi,¡¡this¡¡is¡¡called¡¡from¡¡client"+''\n''); LogService.instance.log(message); //¹¹ÔìÏûÏ¢ÈÕÖ¾£¬Ê¹ÓÃLogService½«ÆäдÈëc:\\paper\\server\\out.tmpÎļþ¡£ message¡¡=¡¡new¡¡Message("c:\\paper\\server\\out.tmp", "Hi,¡¡this¡¡is¡¡called¡¡from¡¡client"+''\n''); LogService.instance.log(message); } }

Çåµ¥ 2. LogService

package¡¡sample.permtest.server; …… public¡¡class¡¡LogService¡¡{ …… public¡¡void¡¡log(Message¡¡message)¡¡{ final¡¡String¡¡destination¡¡=¡¡message.getDestination(); final¡¡String¡¡info¡¡=¡¡message.getInfo(); FileWriter¡¡filewriter¡¡=¡¡null; try¡¡ { filewriter¡¡=¡¡new¡¡FileWriter(destination,¡¡true); filewriter.write(info); filewriter.close(); } catch¡¡(IOException¡¡ioexception) { ioexception.printStackTrace(); } } }

»ùÓÚJava 2ÔËÐÐʱ°²È«Ä£Ð͵ÄÏß³ÌЭ×÷(3)

ʱ¼ä:2009-11-09 IBM ÀîÈýºì

ÈçÇåµ¥ 1¡¢2 Ëùʾ£¬Õâ¾ÍÊÇÒ»¸öÆÕͨµÄ Java Ó¦ÓóÌÐò¡£ÎÒÃÇ°ÑÕâ¸ö³ÌÐò·ÅÔÚ Java µÄ°²È«Ä£ÐÍÖÐÖ´ÐС£Client Àà·ÅÔÚ client.jar JAR °üÀ¶ø LogService Àà·ÅÔÚ server.jar JAR °üÀï

Ê×ÏÈÎÒÃÇʹÓà keytool ¹¤¾ßÀ´Éú³ÉÎÒÃÇÐèÒªµÄ keystore Îļþ£¬ÒÔ¼°ÐèÒªµÄÊý×ÖÖ¤Ê飬ÈçÇåµ¥ 3 Ëùʾ¡£

Çåµ¥ 3. Éú³É keystore Îļþ¼°ÆäÊý×ÖÖ¤Êé

>keytool¡¡-genkey¡¡-alias¡¡client¡¡-keyalg¡¡RSA¡¡-keystore¡¡C:\paper\.keystore >keytool¡¡-genkey¡¡-alias¡¡server¡¡-keyalg¡¡RSA¡¡-keystore¡¡C:\paper\.keystore

ÔÚÇåµ¥ 3 ÖУ¬ÎÒÃÇÉú³ÉÁË C:\paper\.keystore Îļþ£¬Ê¹Óà RSA Ëã·¨Éú³ÉÁ˱ðÃûΪ client Óë server µÄÁ½¸öÊý×ÖÖ¤Êé¡££¨×¢ : Ϊ·½±ãÆð¼û£¬keystore Óë client£¬server Ö¤ÊéµÄÃÜÔ¿¶¼ÊÇ 111111£©

ÎÒÃÇʹÓÃÈçÇåµ¥ 4 ËùʾµÄÃüÁîÀ´Ç©Ãû client.jar Óë server.jar¡£

Çåµ¥ 4. Ç©Ãû JAR Îļþ

>jarsigner.exe¡¡-keystore¡¡C:\paper\.keystore -storepass¡¡111111¡¡c:\paper\client.jar¡¡client >jarsigner.exe¡¡-keystore¡¡C:\paper\.keystore -storepass¡¡111111¡¡c:\paper\server.jar¡¡server

ÔÚÇåµ¥ 4 ÖУ¬ÎÒÃÇʹÓÃÁ˱ðÃûΪ client µÄÊý×ÖÖ¤ÊéÀ´Ç©Ãû client.jar Îļþ£¬Ê¹ÓñðÃûΪ server µÄÊý×ÖÖ¤ÊéÀ´Ç©Ãû server.jar Îļþ¡£

ʹÓÃͼÐλ¯µÄ¹¤¾ß policytool.exe ´´½¨Çåµ¥ 5 ËùʾµÄ Policy Îļþ¡£

Çåµ¥ 5. Policy Îļþ

/*¡¡AUTOMATICALLY¡¡GENERATED¡¡ON¡¡Thu¡¡May¡¡14¡¡15:40:25¡¡CST¡¡2009*/ /*¡¡DO¡¡NOT¡¡EDIT¡¡*/ keystore¡¡"file:////C:/paper/.keystore"; grant¡¡signedBy¡¡"client"¡¡{ permission¡¡java.io.FilePermission¡¡"c:\\paper\\client\\*","read,write"; }; grant¡¡signedBy¡¡"server"¡¡{ permission¡¡java.security.AllPermission; };¡¡

Policy ÎļþÖ¸³ö£¬ËùÓб»”client”Ç©ÃûµÄ´úÂë¾ßÓжÁд” c:\\paper\\client\\”Ŀ¼ÏÂËùÓÐÎļþµÄȨÏÞ£¬¶øËùÓб»”server”Ç©ÃûµÄ´úÂë¾ßÓÐËùÓеÄȨÏÞ¡£Java ½«¸ù¾Ý¸Ã²ßÂÔÎļþ°´ÕÕÇ©ÃûÕß´´½¨ÏàÓ¦µÄ±£»¤Óò¡£

Ò»ÇоÍÐ÷£¬ÎÒÃÇÔËÐдúÂ룬ÈçÇåµ¥

ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»!

·ÖÏíµ½£º ¸ü¶à
Äã¿ÉÄܶÔÏÂÃæµÄÎÄÕ¸ÐÐËȤ
    HTTP/1.1 401 Access Denied âË®¾§ÖʸÐË®¾§Æ»¹û

Copyright ©1999-2011 ÏÃÃÅÁèÖڿƼ¼ÓÐÏÞ¹«Ë¾ ÏÃÃÅÓÅͨ»¥Áª¿Æ¼¼¿ª·¢ÓÐÏÞ¹«Ë¾ All rights reserved

µØÖ·(ADD)£ºÏÃÃÅÈí¼þÔ°¶þÆÚÍûº£Â·63ºÅ701E£¨¶«ÄÏÈÚͨÅÔ£© Óʱà(ZIP)£º361008

µç»°£º0592-5908028 ´«Õ棺0592-5908039 ×ÉѯÐÅÏ䣺web@lingzhong.cn ×ÉѯOICQ£º173723134

¡¶ÖлªÈËÃñ¹²ºÍ¹úÔöÖµµçÐÅÒµÎñ¾­ÓªÐí¿ÉÖ¤¡·ÃöB2-20100024  ICP±¸°¸:ÃöICP±¸05037997ºÅ