@@ -19,26 +19,32 @@ public class JaasConfiguration extends Configuration {
19
19
private final Configuration delegate ;
20
20
private AppConfigurationEntry [] defaultValue ;
21
21
22
- private static AppConfigurationEntry [] generateDefaultConfiguration () {
23
- if (Util .isIBM ()) {
24
- Map <String , String > confDetailsWithoutPassword = new HashMap <>();
25
- confDetailsWithoutPassword .put ("useDefaultCcache" , "true" );
26
- Map <String , String > confDetailsWithPassword = new HashMap <>();
27
- // We generated a two configurations fallback that is suitable for password and password-less authentication
28
- // See
29
- // https://www.ibm.com/support/knowledgecenter/SSYKE2_8.0.0/com.ibm.java.security.component.80.doc/security-component/jgssDocs/jaas_login_user.html
30
- final String ibmLoginModule = "com.ibm.security.auth.module.Krb5LoginModule" ;
31
- return new AppConfigurationEntry [] {
32
- new AppConfigurationEntry (ibmLoginModule , AppConfigurationEntry .LoginModuleControlFlag .SUFFICIENT ,
33
- confDetailsWithoutPassword ),
34
- new AppConfigurationEntry (ibmLoginModule , AppConfigurationEntry .LoginModuleControlFlag .SUFFICIENT ,
35
- confDetailsWithPassword )};
36
- } else {
22
+ private static AppConfigurationEntry [] generateDefaultConfiguration () throws SQLServerException {
23
+ try {
24
+ Class .forName ("com.sun.security.auth.module.Krb5LoginModule" );
37
25
Map <String , String > confDetails = new HashMap <>();
38
26
confDetails .put ("useTicketCache" , "true" );
39
27
return new AppConfigurationEntry [] {
40
28
new AppConfigurationEntry ("com.sun.security.auth.module.Krb5LoginModule" ,
41
29
AppConfigurationEntry .LoginModuleControlFlag .REQUIRED , confDetails )};
30
+ } catch (ClassNotFoundException e ) {
31
+ try {
32
+ Class .forName ("com.ibm.security.auth.module.Krb5LoginModule" );
33
+ Map <String , String > confDetailsWithoutPassword = new HashMap <>();
34
+ confDetailsWithoutPassword .put ("useDefaultCcache" , "true" );
35
+ Map <String , String > confDetailsWithPassword = new HashMap <>();
36
+ // We generated a two configurations fallback that is suitable for password and password-less authentication
37
+ // See
38
+ // https://www.ibm.com/support/knowledgecenter/SSYKE2_8.0.0/com.ibm.java.security.component.80.doc/security-component/jgssDocs/jaas_login_user.html
39
+ final String ibmLoginModule = "com.ibm.security.auth.module.Krb5LoginModule" ;
40
+ return new AppConfigurationEntry [] {
41
+ new AppConfigurationEntry (ibmLoginModule , AppConfigurationEntry .LoginModuleControlFlag .SUFFICIENT ,
42
+ confDetailsWithoutPassword ),
43
+ new AppConfigurationEntry (ibmLoginModule , AppConfigurationEntry .LoginModuleControlFlag .SUFFICIENT ,
44
+ confDetailsWithPassword )};
45
+ } catch (ClassNotFoundException ex ) {
46
+ throw new SQLServerException (SQLServerException .getErrString ("R_moduleNotFound" ), null );
47
+ }
42
48
}
43
49
}
44
50
@@ -47,8 +53,10 @@ private static AppConfigurationEntry[] generateDefaultConfiguration() {
47
53
*
48
54
* @param delegate
49
55
* a possibly null delegate
56
+ * @throws SQLServerException
57
+ * if neither Kerberos module is found: com.sun.security.auth.module.Krb5LoginModule or com.ibm.security.auth.module.Krb5LoginModule
50
58
*/
51
- JaasConfiguration (Configuration delegate ) {
59
+ JaasConfiguration (Configuration delegate ) throws SQLServerException {
52
60
this .delegate = delegate ;
53
61
this .defaultValue = generateDefaultConfiguration ();
54
62
}
0 commit comments