Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
omelett
Posts: 3
Registered: ‎04-19-2012
My Device: 9900
My Carrier: SK Telecom

java.lang.SecurityException: JSR 177 access for this connection is not permitted

I tried running the following code to open an APDUConnection with a UICC based SIM card . I already receivced NFCR signing key and registered.
 
 

 public byte[] openChannel(byte[] aid) throws SException {
  byte[] res = null;
  
  try{
     SecureElement se = SecureElementManager.getInstance().getSecureElement(SecureElement.SIM);
     String uri = se.getUri(aid);

  

     conn = (APDUConnection)Connector.open(uri);  // uri is returned  apdu:0;target=ffffffa0.0.0.0.3.0.0.0
      res = new byte[]{(byte) 0x90,(byte) 0x00};
  }catch (IOException e) {
     throw new SException(SExceptionInfo.NOT_OPEN_CONNECT);
  } catch (Exception e) {
     logger.error(e.toString(), e);
  }
  
  return res;
 }


I got the following Exception:

Class: SecurityException

java.lang.IllegalArgumentException: Invalid AID

 
So I tried to open an APDU connection using the URI direnctly
APDUConnection connection = (APDUConnection)Connector.open("apdu:0;target=a0.00.00.00.03.00.00.00"); 
 
and then I got the following Exception:
Class: SecurityException
Message: JSR 177 access for this connection is not permitted
Please use plain text.
BlackBerry Development Advisor (Retired)
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: java.lang.SecurityException: JSR 177 access for this connection is not permitted

[ Edited ]

The BAD AID is a consequence of getUri() having a known issue. See NFC developer FAQ #13

 

http://supportforums.blackberry.com/t5/Java-Development/NFC-Developer-FAQ/ta-p/1634793

 

The JSR177 "...connection.... not permitted" error probably relates to the existence of an Access Control File (ACF) on the UICC.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Please use plain text.