Does anyone know how to set policy file, so applet can connect other host?

I have an signed applet, it may connect to other host.
The applet should display a HTML pages, which may contains image tag points to a picture stored anywhere. I use a JTextPane to display this HTML page, but when it is loaded. a error occurs.
java.lang.SecurityException
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at sun.awt.image.URLImageSource.checkSecurity(Unknown Source)
at sun.awt.image.ImageRepresentation.imageComplete(Unknown Source)
at sun.awt.image.InputStreamImageSource.errorConsumer(Unknown Source)
at sun.awt.image.InputStreamImageSource.setDecoder(Unknown Source)
at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source)
at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
at sun.awt.image.ImageFetcher.run(Unknown Source)
I have those kind of error (connection refused) before I signed my applet and write policy file to granr socketpermission to the codebase of my class files. But this error still occurs. I suppose it is because the sun.awt.image.* is Java standard class, so my policy file has no effect on them. But how can I make it works?

you need to install the jre, and place the win32.dll at JavaSoft\JRE\1.3.1_06\bin, that properties file place at JavaSoft\JRE\1.3.1_06\lib, comm.jar at JavaSoft\JRE\1.3.1_06\lib\ext\
and in ur code try to use it to open ur com port
public String test() {
String drivername = "com.sun.comm.Win32Driver";
try
CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
catch (Throwable th)
{* Discard it */}
drivername = "javax.comm.*";
try
CommDriver driver = (CommDriver) Class.forName(drivername).newInstance(); driver.initialize();
catch (Throwable th)
{* Discard it */}
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals("COM2")) {
//if (portId.getName().equals("/dev/term/a")) {
try {
serialPort = (SerialPort)
portId.open("SimpleWriteApp", 2000);
} catch (PortInUseException e) {}
try {
outputStream = serialPort.getOutputStream();
} catch (IOException e) {}
try {
serialPort.setSerialPortParams(9600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e) {}
int i=0;
while(true)
try {
messageString="hi";
System.out.println(i++);
outputStream.write(messageString.getBytes());
} catch (IOException e)
System.out.println(e);
messageString=String.valueOf(e);
return messageString;
and yet u need to signed the applet
1. Compile the applet
2. Create a JAR file
3. Generate Keys
4. Sign the JAR file
5. Export the Public Key Certificate
6. Import the Certificate as a Trusted Certificate
7. Create the policy file
8. Run the applet
Susan
Susan bundles the applet executable in a JAR file, signs the JAR file, and exports the public key certificate.
1. Compile the Applet
In her working directory, Susan uses the javac command to compile the SignedAppletDemo.java class. The output from the javac command is the SignedAppletDemo.class.
javac SignedAppletDemo.java
2. Make a JAR File
Susan then makes the compiled SignedAppletDemo.class file into a JAR file. The -cvf option to the jar command creates a new archive (c), using verbose mode (v), and specifies the archive file name (f). The archive file name is SignedApplet.jar.
jar cvf SignedApplet.jar SignedAppletDemo.class
3. Generate Keys
Susan creates a keystore database named susanstore that has an entry for a newly generated public and private key pair with the public key in a certificate. A JAR file is signed with the private key of the creator of the JAR file and the signature is verified by the recipient of the JAR file with the public key in the pair. The certificate is a statement from the owner of the private key that the public key in the pair has a particular value so the person using the public key can be assured the public key is authentic. Public and private keys must already exist in the keystore database before jarsigner can be used to sign or verify the signature on a JAR file.
In her working directory, Susan creates a keystore database and generates the keys:
keytool -genkey -alias signFiles -keystore susanstore -keypass kpi135 -dname "cn=jones" -storepass ab987c
This keytool -genkey command invocation generates a key pair that is identified by the alias signFiles. Subsequent keytool command invocations use this alias and the key password (-keypass kpi135) to access the private key in the generated pair.
The generated key pair is stored in a keystore database called susanstore (-keystore susanstore) in the current directory, and accessed with the susanstore password (-storepass ab987c).
The -dname "cn=jones" option specifies an X.500 Distinguished Name with a commonName (cn) value. X.500 Distinguished Names identify entities for X.509 certificates.
You can view all keytool options and parameters by typing:
keytool -help
4. Sign the JAR File
JAR Signer is a command line tool for signing and verifying the signature on JAR files. In her working directory, Susan uses jarsigner to make a signed copy of the SignedApplet.jar file.
jarsigner -keystore susanstore -storepass ab987c -keypass kpi135 -signedjar SSignedApplet.jar SignedApplet.jar signFiles
The -storepass ab987c and -keystore susanstore options specify the keystore database and password where the private key for signing the JAR file is stored. The -keypass kpi135 option is the password to the private key, SSignedApplet.jar is the name of the signed JAR file, and signFiles is the alias to the private key. jarsigner extracts the certificate from the keystore whose entry is signFiles and attaches it to the generated signature of the signed JAR file.
5. Export the Public Key Certificate
The public key certificate is sent with the JAR file to the whoever is going to use the applet. That person uses the certificate to authenticate the signature on the JAR file. To send a certificate, you have to first export it.
The -storepass ab987c and -keystore susanstore options specify the keystore database and password where the private key for signing the JAR file is stored. The -keypass kpi135 option is the password to the private key, SSignedApplet.jar is the name of the signed JAR file, and signFiles is the alias to the private key. jarsigner extracts the certificate from the keystore whose entry is signFiles and attaches it to the generated signature of the signed JAR file.
5: Export the Public Key Certificate
The public key certificate is sent with the JAR file to the whoever is going to use the applet. That person uses the certificate to authenticate the signature on the JAR file. To send a certificate, you have to first export it.
In her working directory, Susan uses keytool to copy the certificate from susanstore to a file named SusanJones.cer as follows:
keytool -export -keystore susanstore -storepass ab987c -alias signFiles -file SusanJones.cer
Ray
Ray receives the JAR file from Susan, imports the certificate, creates a policy file granting the applet access, and runs the applet.
6. Import Certificate as a Trusted Certificate
Ray has received SSignedApplet.jar and SusanJones.cer from Susan. He puts them in his home directory. Ray must now create a keystore database (raystore) and import the certificate into it. Ray uses keytool in his home directory /home/ray to import the certificate:
keytool -import -alias susan -file SusanJones.cer -keystore raystore -storepass abcdefgh
7. Create the Policy File
The policy file grants the SSignedApplet.jar file signed by the alias susan permission to create newfile (and no other file) in the user's home directory.
Ray creates the policy file in his home directory using either policytool or an ASCII editor.
keystore "/home/ray/raystore";
// A sample policy file that lets a JavaTM program
// create newfile in user's home directory
// Satya N Dodda
grant SignedBy "susan"
permission java.security.AllPermission;
8. Run the Applet in Applet Viewer
Applet Viewer connects to the HTML documents and resources specified in the call to appletviewer, and displays the applet in its own window. To run the example, Ray copies the signed JAR file and HTML file to /home/aURL/public_html and invokes Applet viewer from his home directory as follows:
Html code :
</body>
</html>
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
width="600" height="400" align="middle"
codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,1,2">
<PARAM NAME="code" VALUE="SignedAppletDemo.class">
<PARAM NAME="archive" VALUE="SSignedApplet.jar">
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
</OBJECT>
</body>
</html>
appletviewer -J-Djava.security.policy=Write.jp
http://aURL.com/SignedApplet.html
Note: Type everything on one line and put a space after Write.jp
The -J-Djava.security.policy=Write.jp option tells Applet Viewer to run the applet referenced in the SignedApplet.html file with the Write.jp policy file.
Note: The Policy file can be stored on a server and specified in the appletviewer invocation as a URL.
9. Run the Applet in Browser
Download JRE 1.3 from Javasoft
good luck! [email protected]
i already give u many tips, i use 2 weeks to try this to success, hopw that u understand that, a result of success is not important, the process of how to get things done is most usefull!

Similar Messages

  • Does anyone know how to set up a macbook pro so that other computers can join me and use my internet connection?

    Does anyone know how to set up a macbook pro so that other computers can join me and use my internet connection?

    Have you set up any security on the Mac Connection Sharing?
    Sorry but I don't use that so I'm not familiar with the settings.
    But if you haven't setup and security the iPhone might not mind but I know most Windows computers do not like to connect to Open WiFi. and make sure it is WPA or WPA2.
    Then again it may be a setting in the connection sharing like some type of MAC filtering or it may simply be that Mac OS X connection sharing only allows one connection at a time. Try disconnecting your phone and then connect the PC.
    As to Linc's response about Windows.
    Windows basically does care about connecting to open, unsecured, WiFi. But it will normally pop up a windows asking "Are myou sure you want to connect to this open network". And a simple click on yes will get you connected and an IP address.
    So this is clearly a Mac OS X problem.

  • TS3899 I can't SEND email from Telus account in Alberta, Canada? Does anyone know how to set up the Outgoing server? Help! And thanks!

    Can't SEND email from Telus account in Alberta, Canada, unless I go to web mail. Does anyone know how to set up the Outgoing server? Incoming is fine. Outgoing used to work. We changed it when we went to another location, and can't get it back. Telus support can't fix it. Neither smtp.telus.net NOR mail.telus.net works for Outgoing server to send mail. Please help! Thanks.

    iOS: Unable to send or receive email
    http://support.apple.com/kb/TS3899
    Can’t Send Emails on iPad – Troubleshooting Steps
    http://ipadhelp.com/ipad-help/ipad-cant-send-emails-troubleshooting-steps/
    Setting up and troubleshooting Mail
    http://www.apple.com/support/ipad/assistant/mail/
    Server does not allow relaying email error, fix
    http://appletoolbox.com/2012/01/server-does-not-allow-relaying-email-error-fix/
    Why Does My iPad Say "Cannot Connect to Server"?
    http://www.ehow.co.uk/info_8693415_ipad-say-cannot-connect-server.html
    iOS: 'Mailbox Locked', account is in use on another device, or prompt to re-enter POP3 password
    http://support.apple.com/kb/ts2621
    iPad Mail
    http://www.apple.com/support/ipad/mail/
    Try this first - Reset the iPad by holding down on the Sleep and Home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons. (This is equivalent to rebooting your computer.)
    Or this - Delete the account in Mail and then set it up again. Settings->Mail, Contacts, Calendars -> Accounts   Tap on the Account, then on the red button that says Remove Account.
     Cheers, Tom

  • Does anyone know how to set up 2 iphones on iCloud?

    Does anyone know how to set up 2 iphones on iCloud using just one macbook pro whilst keeping contacts, iTunes etc separate? My wife and I both have a new iPhone 4s but want to keep everything seperate.
    Many Thanks

    gnormg wrote:
    My wife and I both have a new iPhone 4s but want to keep everything seperate.
    Then you need separate Apple ID's & iCloud accounts. This is required if you want to use things like iMessage, FaceTime & iCloud and not have a mess on your hands.

  • Does anyone know how to save a file in CC 10.0 or higher that is viewable in CC 9.2?

    I am trying to make my fiels viewable to someone who has Adobe CC version 9.2, but I have version 10.0. Does anyone know how to save my files so the are readable?

    You will likely get better program help in a program forum
    The Cloud forum is not about using individual programs
    The Cloud forum is about the Cloud as a delivery & install process
    If you will start at the Forums Index https://forums.adobe.com/welcome
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says All communities) to open the drop down list and scroll

  • Does anyone know how to set alerts in the iCloud calendar of Outlook 2010 for PC?

    Does anyone know how to set alerts in the iCloud calendar on Microsoft Outlook 2010 for a PC?  Outlook gives me a warning message and does not allow me to save alerts for calendar events created in iCloud calendar.  It will allow me to save events in the non-iCloud calendars.

    Ignore what office says, when the warning comes up saying that the reminder will not work click on yes,
    I just tested it and i had the reminder on my ihpone in outlook and also as i had the calendar open in safari it popped up on there too ( I wasn't aware it did that)

  • Does anyone know how to copy my files from my ipod to a different computer?

    Does anyone know how to copy my files from my ipod to a different computer? I tried to do it, but all that it did was erase my files. What i want to to is use my ipod to transfer my files to another computer (which has itunes as well) PLEASE help!

    You will need to enable your iPod for disk use. Then, you should see your iPod in "My Computer" and you can open up your iPod's folder there and drag the files into it. You can store the files on the iPod, then connect it to the other computer and drag-and-drop them from the iPod into the designated directory in that computer. Make sure individual files are not larger than 4 GB.

  • Epson Artisan 810 in duplex printing, reverses the second page, so that it is upside down in relation to the first page. Does anyone know how to set the second page i.e the reverse side of the page, in the correct direction?in the

    Epson Artisan 810 in duplex printing, reverses the second page, so that it is upside down in relation to the first page. Does anyone know how to set the second page.... i.e the reverse side of the page.....in the correct direction?
    It worked perfectly last week, now there are problems.
    Thanks for any advice.

    Epson Artisan 810 in duplex printing, reverses the second page, so that it is upside down in relation to the first page. Does anyone know how to set the second page.... i.e the reverse side of the page.....in the correct direction?
    It worked perfectly last week, now there are problems.
    Thanks for any advice.

  • Does anyone know how to set up the cname in PLESK correctly?

    Hi, does anyone know how to set up the cname correctly in a PLESK control panel?
    I am trying to point my domain name to my .mac webspace using the new feature available for iWeb 08.
    I can see the cname category in the DNS setup on the control panel and have changed the cname www to web.mac.com as described and have waited over 48 hours and still no change. I just want to rule all avenues out before approaching my hosting company.
    Thanks in advance to anyone that has the jnowledge to help.

    Well, no one bothered to answer, that's a first. Managed to sort it out on my own though.

  • Does anyone know how to set up the wireless router when y...

    does anyone know how to set up the wireless router when you have a Vonage modem and a cable modem?  HELP!

    You mean u got 2 modems ?
    C | EH
    linksyshelp.blogspot.com

  • Hi, Does anyone know how to set up facetime on my mac and iphone?

    Hi  Does anyone know how to set up facetime on my mac and iphone?

    Page 68 of the user guide:
    http://support.apple.com/manuals/

  • I have suddenly been getting a lot of fraud emails.  Does anyone know how to set up blocks?

    Hello,
    I have been suddenly getting tons of fraud emails.  This has never been a problem in my mack mail in the past. Does anyone know how to set up blocks?  I have searched through preferences but have not been able to find any way to do it.  Bounce is of no use as these emails are not "respondable".
    Gabrielle

    Hi Gabrielle,
    If you're using Mail, open Mail > Mail menu > Preferences > Rules > Add Rule > set the parameters you want.

  • Does anyone know how to set up iphone on itunes I lost devise and IOS?

    Does anyone know how to set up Iphohe on itunes? I no longer am detected and lost IOS.

    Not exactly sure what you mean by lost iOS?
    But on your computer first make sure you have iTunes 11.1 or later.

  • HT201320 DOES ANYONE KNOW HOW TO SET-UP A SHAW ACCOUNT FOR SENIDNG EMAIL

    does anyone know how to set-up shaw as an outgoing email account?

    Just Google for:
    setup shaw mail on iphone.

  • Does anyone know how to set up eircom mail on an iPad 3. Tks Charles

    Does anyone know how to set up eircom mail on an ipad 3? Many thanks Charles

    - Have you looked at the previous discussions on the right side of the page under the heading "More Like This". The one with the green checkmark is solved.
    - Have you Googled for:
    setup eircom mail on iphone

Maybe you are looking for

  • How can I define a default character enconding for Firefox 4?

    Dear Sirs, I would like to know how can I change the character encoding of Firefox 4 to Western (ISO-8859-1) and keep that character enconding as the default every time I open Firefox 4. I have noticed the every time I change the default character en

  • MI Post Installation Process missing template installer

    Hi All, I have installed MI Server (ABAP + JAVA Stacks) as a stand alone machine, also done the configuration steps <b>manually</b> for enabling mobile administrator in nwa. But getting issues while creating JCO's and unable to solve them, so I thoug

  • How to use Java classes to make any query from Ldap? (any sample)

    Where to find at least a brief description? I need links,samples Thanks in advance.

  • Mail And RSS Feeds

    I've been seeing a lot of RSS apps on the appstore and on websites. I've read through some product descriptions and they all do just about the same thing: compile feeds. Mac Mail seems to handle RSS' just fine, and other than having to update the fee

  • Status: Pending on Texts Sent

    I have sent a text message and on the message report is says "Status: Pending"  Anyone know what this means?  Did my message go through?  The message was sent a few weeks ago and it still says the same thing.  Thoughts?  I do not want to send anymore