javax.sound.sampled.AudioPermission" "record" in java applets

463 Views Asked by At

I have created an applet with following structure

    - EXAMPLE
         -WEB-INF
            -web.xml
         -index.jsp
         -AudioApplet.java

When i compile AudioApplet file i got 5 .class files.Then i ran following command to create the jar file with all the .class files.

   jar cvf *.class

After creating the jar file i placed that jar file in the same folder.And in my jsp code is

<applet
  code="AudioApplet.class"
  archive="jar name"
  width="450" height="250">

C:\Program Files\Java\jdk1.6.0_21\bin>keytool -genkey -keystore myKeystore -alias myVoice

Enter keystore password:  
Re-enter new password:  
What is your first and last name?  
  [Unknown]:  AAAAA
What is the name of your organizational unit?  
  [Unknown]:  xxxxxx  
What is the name of your organization?  
  [Unknown]:  yyyyy  
What is the name of your City or Locality?  
  [Unknown]:  chennai  
What is the name of your State or Province?  
  [Unknown]:  tn  
What is the two-letter country code for this unit?  
  [Unknown]:  in  
Is CN=Saravanan, OU=xxxxx, O=yyyyy, L=chennai, ST=tn, C=in correct?  
  [no]: yes  


Enter key password for <myVoice>  
        (RETURN if same as keystore password):  
Re-enter new password:

I sign the applet like this.And i am getting the error

java.security.AccessControlException: access denied ("javax.sound.sampled.AudioPermission" "record")  
at java.security.AccessControlContext.checkPermission(Unknown Source)  
at java.security.AccessController.checkPermission(Unknown Source)  
at java.lang.SecurityManager.checkPermission(Unknown Source)  
at sun.plugin2.applet.AWTAppletSecurityManager.checkPermission(Unknown Source)  
at com.sun.media.sound.JSSecurityManager.checkRecordPermission(Unknown Source)  
at com.sun.media.sound.DirectAudioDevice$DirectDL.implOpen(Unknown Source 
.................

When i click on one of the button which will record voice.

What might be the wrong here.I am new to applets.Thanks in advance...

1

There are 1 best solutions below

2
On

A command keytool -genkey -keystore myKeystore -alias myVoice just creates key, and it doesn't sign jar.

To sign jar, use jarsigner --keystore myKeystore foo.jar myVoice