2012-05-22 15 views
6

UICC ve Güvenli Öğeler için yeni ve bu eğiticiyi kullanarak basit bir android uygulaması yapmayı denedim (http://code.google.com/p/seek-for- Güvenli Öğeleri bağlamak için android/wiki/UsingSmartCardAPI). I uygulama çalıştırdığınızda bir java.lang.SecurityException atmak: Bağlantı reddedildi !!!. Lütfen yardım et. Teşekkürandroid - java.lang.SecurityException: Bağlantı reddedildi

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()); 
       } 

    } 

logcat

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) 

Manifest kod

<?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> 
+0

logcat out koydu, resim değil – Aerrow

+0

manifest.xml dosyanızı yükleyebilirsin. –

+0

manifest ve log eklendi ... –

cevap

4

// Define AndroidManifest.xml izni dosya

<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="org.simalliance.openmobileapi.SMARTCARD"/> 
+0

Zaten akıllı kart izin var. Neden internete ihtiyacım var? –

+0

ya ihtiyacın yok. Eğer web servis talep etmiyorsanız. –

+0

no ... webservice erişimim yok .. UICC simine bağlanmak için başka bir yol var mı ...? –