×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    42

    urgent Solution for Security Exception

    I am getting the following exception

    Application not authorized to access the restricted API--java.lang.SecurityException:

    when i am rejecting the sms.

    any solution will be quite helpful and it's urgent

  2. #2
    Regular Contributor
    Join Date
    Sep 2008
    Location
    Ahmedabad
    Posts
    254

    Re: urgent Solution for Security Exception

    Hi,

    Can you specify which are the API's that you are trying to use? And have you set the permisssions for those API's in jad file.

    For example if you are using PushRegistry you have to include the permission such as MIDlet-permission and then you provide the api for which you need.

    Check whether you have mentioned this things or not?
    Sunil
    Mobile Application Developer

  3. #3
    Registered User
    Join Date
    Jul 2008
    Posts
    42

    Re: urgent Solution for Security Exception

    thought i changed the jad file with midlet permission for push register it is not accepting

  4. #4
    Registered User
    Join Date
    Sep 2007
    Location
    Bangalore
    Posts
    868

    Re: urgent Solution for Security Exception

    Hi praran910,
    When you are using the WMAAPI when ever you send the sms it will ask the user to send the sms to the specifying number this question is put by AMS if you say yes it will send the sms . If you say No it will throw the -java.lang.SecurityException . This is the API Behavior is like this.If you say no for SMS sending It will throw the SecurityException

  5. #5
    Registered User
    Join Date
    Jul 2008
    Posts
    42

    Re: urgent Solution for Security Exception

    is there a solution to handle this exception.


    And if we say no to sms then the application will not again call the sms function again in the application

  6. #6
    Registered User
    Join Date
    Sep 2007
    Location
    Bangalore
    Posts
    868

    Re: urgent Solution for Security Exception

    Hi ,
    What kind of a setting you have in your mobile for messaging is it ask every time or ask once?

  7. #7
    Registered User
    Join Date
    Jul 2008
    Posts
    42

    Re: urgent Solution for Security Exception

    i don't know abt that and i did not put any restriction of that type.

  8. #8
    Registered User
    Join Date
    Sep 2007
    Location
    Bangalore
    Posts
    868

    Re: urgent Solution for Security Exception

    Ok ,
    Are you closing the connection after you get the sequrity exception?
    Do closing the connection in finally block see the result.

  9. #9
    Regular Contributor
    Join Date
    Sep 2008
    Location
    Ahmedabad
    Posts
    254

    Re: urgent Solution for Security Exception

    Hi,

    Yes its correct that if you say no to send SMS then it will generate Security Exception. To avoid this have you tried putting a catch for SecurityException? If not then try to do that and see what happens.

    One more thing I dont think you can set the midlet settings in such a way that it will ask for the confirmation only once for SMS. It can be done for using GPRS and media facilities but not for sending SMS.

    Hope this helps you out.
    Sunil
    Mobile Application Developer

  10. #10
    Registered User
    Join Date
    Jul 2008
    Posts
    42

    Re: urgent Solution for Security Exception

    if i am closing the connection it is giving null pointer exception.
    i tried in finally block and also in the catch

  11. #11
    Regular Contributor
    Join Date
    Sep 2008
    Location
    Ahmedabad
    Posts
    254

    Re: urgent Solution for Security Exception

    Hi,

    Dont close the connection just try to catch the exception suppose

    try
    {
    /* Your code for sending sms */
    }
    catch(SecurityException se)
    {
    Print out any statememt to check whether its going in the catch or not.
    }
    Sunil
    Mobile Application Developer

  12. #12
    Registered User
    Join Date
    Jul 2008
    Posts
    42

    Re: urgent Solution for Security Exception

    i caught the exception in the catch block but not able to solve the problem.

    Please help.

  13. #13
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: urgent Solution for Security Exception

    Hi praran910,
    Yeah while accessing the network, is can be while sending the SMS or calling a URL ..AMS ask for the permission in order to make sure .Therefore you can allow or deny.

    If you deny then AMS throws an exception called as security exception
    Therefore you must catch the same..and then you can draw the screen explaining the same..then just close the connection..does not matter which connection it was...try to follow the code

    HttpConnection hc = null;
    InputStream in = null;

    try {
    // Now make a connection to the server.
    hc = (HttpConnection)Connector.open(url);

    // Retrieve the response.
    in = hc.openInputStream();

    int length = 256;
    byte[] raw = new byte[length];
    int readLength = in.read(raw);

    String message = new String(raw, 0, readLength);
    resultsForm.append(message);
    }
    catch (Exception e) {
    resultsForm.append(
    new StringItem("Exception: ", e.toString()));
    }
    finally {
    if (in != null) {
    try { in.close(); }
    catch (IOException ioe) {}
    }
    if (hc != null) {
    try { hc.close(); }
    catch (IOException ioe) {}
    }
    }
    ..

    //for SMS
    http://www.java-tips.org/java-me-tip...-device-3.html
    Thanks,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. s60 3rd ed emulator crash
    By Kimau in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2008-06-18, 22:12
  2. Location Exception
    By success_anil in forum Mobile Java General
    Replies: 2
    Last Post: 2008-02-27, 12:03
  3. exception thrown but where?
    By jonneymendoza in forum Mobile Java General
    Replies: 2
    Last Post: 2007-09-26, 09:02
  4. can not successfully link any sample using .NET
    By lobotomat in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2002-08-20, 00:29

Posting Permissions

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