@@ -51,6 +51,8 @@ public class EAPMetadata extends Activity {
51
51
static Button discard ,install ;
52
52
ProfilesStorage db = new ProfilesStorage (this );
53
53
String keyPass ="" ; //default to nothing to start (optional)
54
+ //global clietn cert value for retry
55
+ static NodeList clientCert ;
54
56
55
57
public boolean testExternalStorage ()
56
58
{
@@ -428,6 +430,21 @@ public void onClick(DialogInterface dialog, int which) {
428
430
.show ();
429
431
// finish();
430
432
}
433
+
434
+ if (eduroamCAT .profiles !=null )
435
+ if (eduroamCAT .profiles .size ()>0 )
436
+ if (eduroamCAT .profiles .get (eduroamCAT .profiles .size ()-1 ).isError ())
437
+ {
438
+ //if eap-tls, request pin again
439
+ int lastAuthMethod = 0 ;
440
+ lastAuthMethod = eduroamCAT .profiles .get (eduroamCAT .profiles .size ()-1 ).getNumberAuthenticationMethods ();
441
+ if (eduroamCAT .profiles .get (eduroamCAT .profiles .size ()-1 ).getAuthenticationMethod (lastAuthMethod -1 ).getOuterEAPType ()==13 )
442
+ if (eduroamCAT .profiles .get (eduroamCAT .profiles .size ()-1 ).getAuthenticationMethod (lastAuthMethod -1 ).getClientPrivateKey ()==null )
443
+ {
444
+ requestKeypass (getString (R .string .PinDialog ),getString (R .string .PinDialog ),this , clientCert );
445
+ eduroamCAT .debug ("No valid auth method in profile. check if tls and req PIN again" );
446
+ }
447
+ }
431
448
}
432
449
433
450
/**
@@ -439,7 +456,7 @@ private void setupActionBar() {
439
456
440
457
}
441
458
442
- public static void requestKeypass (String message , String title , Activity activ , final NodeList clientCert , final AuthenticationMethod newAuthMethod )
459
+ public static void requestKeypass (String message , String title , Activity activ , final NodeList clientCertx )
443
460
{
444
461
// Set an EditText view to get user input
445
462
final EditText input = new EditText (activ );
@@ -453,7 +470,7 @@ public void onClick(DialogInterface dialog, int which) {
453
470
eduroamCAT .debug ("PIN=" + pin );
454
471
String certstring = "" ;
455
472
Element Clientcert = null ;
456
-
473
+ if ( clientCertx . getLength ()> 0 ) clientCert = clientCertx ;
457
474
if (clientCert .getLength () > 0 ) {
458
475
for (int s = 0 ; s < clientCert .getLength (); s ++) {
459
476
Clientcert = (Element ) clientCert .item (s );
@@ -478,13 +495,16 @@ public void onClick(DialogInterface dialog, int which) {
478
495
if (aAuthMethod .getOuterEAPType ()==13 )
479
496
try {
480
497
eduroamCAT .debug ("adding client cert:" +tmp + "with pin " +pin );
481
- aAuthMethod .loadClientCert (tmp , Clientcert .getAttribute ("format" ), Clientcert .getAttribute ("encoding" ), pin );
482
- aAuthMethod .setClientCertPass (pin );
483
- aProfile .removeAuthenticationMethod (i );
484
- aProfile .addAuthenticationMethod (aAuthMethod );
485
- eduroamCAT .profiles .set (eduroamCAT .profiles .size () - 1 ,aProfile );
498
+ if (aAuthMethod .loadClientCert (tmp , Clientcert .getAttribute ("format" ), Clientcert .getAttribute ("encoding" ), pin )) {
499
+ aAuthMethod .setClientCertPass (pin );
500
+ aProfile .removeAuthenticationMethod (i );
501
+ aProfile .addAuthenticationMethod (aAuthMethod );
502
+ eduroamCAT .profiles .set (eduroamCAT .profiles .size () - 1 , aProfile );
503
+ }
504
+ else eduroamCAT .profiles .get (eduroamCAT .profiles .size ()-1 ).setConfigError ("Client cert error" );
486
505
} catch (KeyStoreException e ) {
487
506
e .printStackTrace ();
507
+ eduroamCAT .profiles .get (eduroamCAT .profiles .size ()-1 ).setConfigError ("Client cert error" );
488
508
}
489
509
}
490
510
}
@@ -493,6 +513,12 @@ public void onClick(DialogInterface dialog, int which) {
493
513
}
494
514
}
495
515
})
516
+ .setNegativeButton (R .string .discard_button , new DialogInterface .OnClickListener () {
517
+ public void onClick (DialogInterface dialog , int which ) {
518
+ //cancel install of
519
+ eduroamCAT .debug ("User discard..." );
520
+ }
521
+ })
496
522
.setView (input )
497
523
.show ();
498
524
}
@@ -630,10 +656,8 @@ public ArrayList<ConfigProfile> parseProfile(String config) throws IOException,
630
656
631
657
//get Client cert
632
658
//get keypass from user
633
- NodeList clientCert = authElement .getElementsByTagName ("ClientCertificate" );
634
- if (clientCert .getLength ()>0 ) requestKeypass ("Enter PIN" ,"Enter PIN" ,this ,clientCert ,newAuthMethod );
635
-
636
-
659
+ clientCert = authElement .getElementsByTagName ("ClientCertificate" );
660
+ if (clientCert .getLength ()>0 ) requestKeypass (getString (R .string .PinDialog ),getString (R .string .PinDialog ),this ,clientCert );
637
661
}
638
662
}
639
663
0 commit comments