android - java.lang.SecurityException: Conexión rechazada
Frecuentes
Visto 2,457 veces
6
Soy nuevo en UICC y Secure Elements e intenté hacer una aplicación de Android simple usando este tutorial (http://code.google.com/p/seek-for-android/wiki/UsingSmartCardAPI) para conectar Secure Elements. Cuando ejecuto la aplicación, arroja una java.lang.SecurityException: ¡Conexión rechazada! Por favor ayuda. Gracias
código
public void onCreate(Bundle savedInstanceState) {
final String LOG_TAG = "HelloSmartcard";
super.onCreate(savedInstanceState);
LinearLayout layout = new LinearLayout(this);
layout.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
Button button = new Button(this);
button.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
button.setText("Click Me");
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
Log.d(LOG_TAG, "Retrieve available readers...");
Reader[] readers = seService.getReaders();
if (readers.length < 1)
return;
Log.d(LOG_TAG, "Create Session from the first reader...");
Session session = readers[0].openSession();
Log.d(LOG_TAG,
"Create logical channel within the session...");
Channel channel = session.openLogicalChannel(new
byte[] {
(byte) 0xD2, 0x76, 0x00, 0x01, 0x18, 0x00, 0x02,
(byte) 0xFF, 0x49, 0x50, 0x25, (byte) 0x89,
(byte) 0xC0, 0x01, (byte) 0x9B, 0x01 });
//Log.d(LOG_TAG, "Send HelloWorld APDU command");
byte[] respApdu = channel.transmit(new byte[] {
(byte) 0x90, 0x10, 0x00, 0x00, 0x00 });
channel.close();
// Parse response APDU and show text but remove SW1 SW2 first
byte[] helloStr = new byte[respApdu.length - 2];
System.arraycopy(respApdu, 0, helloStr, 0,
respApdu.length - 2);
Toast.makeText(MainActivity.this, new
String(helloStr), Toast.LENGTH_LONG).show();
} catch (Exception e) {
Log.e(LOG_TAG, "Error occured:", e);
return;
}
}
});
layout.addView(button);
setContentView(layout);
try {
Log.i(LOG_TAG, "creating SEService object");
seService = new SEService(this, this);
} catch (SecurityException e) {
Log.e(LOG_TAG, "Binding not allowed, uses-permission org.simalliance.openmobileapi.SMARTCARD?");
} catch (Exception e) {
Log.e(LOG_TAG, "Exception: " + e.getMessage());
}
}
gato de registro
05-22 08:11:49.669: E/HelloSmartcard(6691): Error occured:
05-22 08:11:49.669: E/HelloSmartcard(6691): java.lang.SecurityException: Connection refused !!!
05-22 08:11:49.669: E/HelloSmartcard(6691): at org.simalliance.openmobileapi.SEService.checkForException(SEService.java:611)
05-22 08:11:49.669: E/HelloSmartcard(6691): at org.simalliance.openmobileapi.SEService.openLogicalChannel(SEService.java:479)
05-22 08:11:49.669: E/HelloSmartcard(6691): at org.simalliance.openmobileapi.Session.openLogicalChannel(Session.java:143)
05-22 08:11:49.669: E/HelloSmartcard(6691): at com.gieseckedevrient.android.hellosmartcard.MainActivity$1.onClick(MainActivity.java:50)
05-22 08:11:49.669: E/HelloSmartcard(6691): at android.view.View.performClick(View.java:2485)
05-22 08:11:49.669: E/HelloSmartcard(6691): at android.view.View$PerformClick.run(View.java:9080)
05-22 08:11:49.669: E/HelloSmartcard(6691): at android.os.Handler.handleCallback(Handler.java:587)
05-22 08:11:49.669: E/HelloSmartcard(6691): at android.os.Handler.dispatchMessage(Handler.java:92)
05-22 08:11:49.669: E/HelloSmartcard(6691): at android.os.Looper.loop(Looper.java:130)
05-22 08:11:49.669: E/HelloSmartcard(6691): at android.app.ActivityThread.main(ActivityThread.java:3768)
05-22 08:11:49.669: E/HelloSmartcard(6691): at java.lang.reflect.Method.invokeNative(Native Method)
05-22 08:11:49.669: E/HelloSmartcard(6691): at java.lang.reflect.Method.invoke(Method.java:507)
05-22 08:11:49.669: E/HelloSmartcard(6691): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
05-22 08:11:49.669: E/HelloSmartcard(6691): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
05-22 08:11:49.669: E/HelloSmartcard(6691): at dalvik.system.NativeStart.main(Native Method)
Manifiesto
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gieseckedevrient.android.hellosmartcard"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="org.simalliance.openmobileapi.SMARTCARD"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="org.simalliance.openmobileapi" android:required="false" />
</application>
</manifest>
1 Respuestas
4
//Definir el permiso en el archivo AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="org.simalliance.openmobileapi.SMARTCARD"/>
contestado el 22 de mayo de 12 a las 09:05
Ya tengo el permiso de la tarjeta inteligente. ¿Por qué necesito internet? - china_82
ya no necesitas eso. si no está solicitando un servicio web. - padma kumar
no... no tengo acceso al servicio web... ¿tienes alguna otra forma de conectarme al sim de la UICC...? - china_82
@chinna_82 El sistema Android se ejecuta en el procesador de la aplicación, por lo que tiene acceso limitado o nulo a la tarjeta SIM. La comunicación con la tarjeta SIM la proporciona el procesador de banda base mediante comandos AT (por ejemplo, AT+CPIN, AT+CRSM) definidos por la especificación 3GPP 27.007 oa través de una interfaz IPC propietaria. - padma kumar
Estoy enfrentando los mismos problemas. Y también dar permiso, pero el problema sigue ahí. ¿Tiene solución... @PadmaKumar - Krunal Indrodiya
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas android smartcard or haz tu propia pregunta.
publicar logcat out put, no una imagen - Aerrow
¿Puedes publicar tu archivo manifest.xml? - Padma Kumar
¿En qué dispositivo con qué imagen ROM de Android está ejecutando este código? - NFC guy