Results 1 to 13 of 13
  1. #1
    bozovilla is offline Member
    Join Date
    Nov 2007
    Posts
    19
    Rep Power
    0

    Default Can't record sound

    Hi, I developed a sound recorder than can playback the file each time after it is recorded. Everything works perfectly fine in the application form. But when I convert to applet, it is unable to perform recording but it is able to playback. Here is the error that I got while trying to record:


    java.security.AccessControlException: access denied (javax.sound.sampled.AudioPe
    rmission record)
    at java.security.AccessControlContext.checkPermission (AccessControlConte
    xt.java:323)
    at java.security.AccessController.checkPermission(Acc essController.java:
    546)
    at java.lang.SecurityManager.checkPermission(Security Manager.java:532)
    at com.sun.media.sound.JSSecurityManager.checkRecordP ermission(JSSecurit
    yManager.java:56)
    at com.sun.media.sound.DirectAudioDevice$DirectDL.imp lOpen(DirectAudioDe
    vice.java:412)
    at com.sun.media.sound.AbstractDataLine.open(Abstract DataLine.java:107)
    at com.sun.media.sound.AbstractDataLine.open(Abstract DataLine.java:139)
    at AudioRecorder02$CaptureThread.run(AudioRecorder02. java:245)

    What should I do? I'm not very advanced with Java.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    access denied (javax.sound.sampled.AudioPermission record)
    How are you running the applet? locally or from a server?

    Looks like you need to give the applet permission to record. For a single user, this can be done with the policytool program. For many users you'll want to sign the applet's jar.

  4. #4
    bozovilla is offline Member
    Join Date
    Nov 2007
    Posts
    19
    Rep Power
    0

    Default Tested

    I've tested it from textpad, where there is an option to run applet. How do I sign an applet? Does it cost money?

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    I take it that from textpad is local, no server involved. In that case if ifs for a single user(you) you can change your local .java.policy file to give yourself permission. There's a discussion on how to do this in the Java Tutorial. Likewise with signing the applet's jar file.

    Here's a sample of what you entry in the .java.policy file might look like. Use a Search on your C: drive to find that file.
    grant codeBase "file://C:/testing" {
    permission javax.sound.sampled.AudioPermission "record";
    };

  6. #6
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Smile java signer tool is free

    Quote Originally Posted by bozovilla View Post
    ....Does it cost money?
    No, it just takes a reading of the docs. If you can get something to show with an applet, let alone what you have posted already, you can sign an applet. Threre are other ways to do it.
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  7. #7
    bozovilla is offline Member
    Join Date
    Nov 2007
    Posts
    19
    Rep Power
    0

    Default Problem with signing applet

    Hi, I have followed all the steps given to sign an applet but i get this error message when i try to import certificate

    After typing this: keytool -import -keystore cacerts -storepass changeit -file applet.crt

    Here is the error:

    keytool error: java.lang.Exception: Certificate not imported, alias <mykey> alre
    ady exists

  8. #8
    bozovilla is offline Member
    Join Date
    Nov 2007
    Posts
    19
    Rep Power
    0

    Default Help!

    I managed to solve that problem of importing the certificate. But now I still get the same error.

  9. #9
    bozovilla is offline Member
    Join Date
    Nov 2007
    Posts
    19
    Rep Power
    0

    Default Help!

    The only way for me to solve the errors are to place these two codes on the java.policy file:

    permission javax.sound.sampled.AudioPermission "record";
    permission java.io.FilePermission "joel.wav", "write";

    I'm sure, this is not the way. How can I do it then? I need to make my file permission more dynamic. Instead of hard coding it here

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Use "<<ALL FILES>>" vs "joel.wav"

    Keep working at signing, I was able to get it to work.

  11. #11
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Post In general, Java security model seems to revolve around permissions.

    Quote Originally Posted by bozovilla View Post
    .....I'm sure, this is not the way. How can I do it then? I need to make my file permission more dynamic. Instead of hard coding it here
    In general, Java security model seems to revolve around permissions. I saw Providers being installed at runtime from code using grant{ .... } or something, but it is way over my head to attempt to provide a clear concise answer. Are you seeking to do a stand-alone for your own use on your machine or are you trying to achieve a distributable app either by applet or by standalone application, having users modifiy policy files is not advisable except for a narrowly targeted set.
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  12. #12
    bozovilla is offline Member
    Join Date
    Nov 2007
    Posts
    19
    Rep Power
    0

    Default still can't record

    I can finally record sound after adding:

    permission javax.sound.sampled.AudioPermission "record";
    permission java.io.FilePermission "<<ALL FILES>>", "write";

    into the java.policy file. But this recording can only be done on the appletviewer. I need to record it over the web. I have signed the jar file, export the public key, and modify the java.policy file by adding:

    keystore "file:C:\Program Files\Java\jre1.6.0_05\lib\security\bubble.jks";

    grant signedBy "bubble" {
    permission java.security.AllPermission;
    };

    I have also imported the certificate with the alias. I am still unable to record over the web. When I turn on the java console in firefox, it gives the error:

    java.security.AccessControlException: access denied (java.io.FilePermission joel.wav read)

  13. #13
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    I signed a jar file for an applet and have posted the HTML for it:
    Applet Reader It prompts me to allow it to do its thing.
    It tries to read the file: C:\AppletTestFile.txt and display its contents.

Similar Threads

  1. selecting a record in database
    By ramachandran in forum New To Java
    Replies: 0
    Last Post: 10-25-2007, 07:06 AM
  2. Replies: 0
    Last Post: 09-28-2007, 01:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •