- // Cache previous value of login conf location
- String oldLoginConfLocation = System
- .getProperty(LOGIN_CONFIG_PROPERTY);
- // Find OS family
- String osName = System.getProperty("os.name");
- final String auth;
- if (osName.startsWith("Windows"))
- auth = "Windows";
- else if (osName.startsWith("SunOS") || osName.startsWith("Solaris"))
- auth = "Solaris";
- else
- auth = "Unix";
-
- Subject subject;
- try {
-
- URL url = getClass().getResource(
- "/org/argeo/security/activemq/osLogin.conf");
-
- System.setProperty(LOGIN_CONFIG_PROPERTY, url.toString());
- LoginContext lc = new LoginContext(auth);
- lc.login();
- subject = lc.getSubject();
- } catch (LoginException le) {
- throw new ArgeoException("OS authentication failed", le);
- } finally {
- if (oldLoginConfLocation != null)
- System.setProperty(LOGIN_CONFIG_PROPERTY,
- oldLoginConfLocation);
- }
-
- // Extract user name
- String osUsername = null;
- for (Principal principal : subject.getPrincipals()) {
- String className = principal.getClass().getName();
- if ("Unix".equals(auth)
- && "com.sun.security.auth.UnixPrincipal"
- .equals(className))
- osUsername = principal.getName();
- else if ("Windows".equals(auth)
- && "com.sun.security.auth.NTUserPrincipal"
- .equals(className))
- osUsername = principal.getName();
- else if ("Solaris".equals(auth)
- && "com.sun.security.auth.SolarisPrincipal"
- .equals(className))
- osUsername = principal.getName();
- }
-
- if (osUsername == null)
- throw new ArgeoException("Could not find OS user name");
-
- uccfa.setUsername(osUsername);
+// if (false) {
+// // Cache previous value of login conf location
+// String oldLoginConfLocation = System
+// .getProperty(LOGIN_CONFIG_PROPERTY);
+// // Find OS family
+// String osName = System.getProperty("os.name");
+// final String auth;
+// if (osName.startsWith("Windows"))
+// auth = "Windows";
+// else if (osName.startsWith("SunOS")
+// || osName.startsWith("Solaris"))
+// auth = "Solaris";
+// else
+// auth = "Unix";
+//
+// Subject subject;
+// // see http://old.nabble.com/osgi-and-jaas-td23485885.html
+// ClassLoader ccl = Thread.currentThread()
+// .getContextClassLoader();
+// try {
+// Thread.currentThread().setContextClassLoader(
+// getClass().getClassLoader());
+// URL url = getClass().getResource(
+// "/org/argeo/security/activemq/osLogin.conf");
+//
+// System.setProperty(LOGIN_CONFIG_PROPERTY, url.toString());
+// LoginContext lc = new LoginContext(auth);
+// lc.login();
+// subject = lc.getSubject();
+// } catch (LoginException le) {
+// throw new ArgeoException("OS authentication failed", le);
+// } finally {
+// if (oldLoginConfLocation != null)
+// System.setProperty(LOGIN_CONFIG_PROPERTY,
+// oldLoginConfLocation);
+// Thread.currentThread().setContextClassLoader(ccl);
+// }
+// // Extract user name
+// String osUsername = null;
+// for (Principal principal : subject.getPrincipals()) {
+// String className = principal.getClass().getName();
+// if ("Unix".equals(auth)
+// && "com.sun.security.auth.UnixPrincipal"
+// .equals(className))
+// osUsername = principal.getName();
+// else if ("Windows".equals(auth)
+// && "com.sun.security.auth.NTUserPrincipal"
+// .equals(className))
+// osUsername = principal.getName();
+// else if ("Solaris".equals(auth)
+// && "com.sun.security.auth.SolarisPrincipal"
+// .equals(className))
+// osUsername = principal.getName();
+// }
+//
+// if (osUsername == null)
+// throw new ArgeoException("Could not find OS user name");
+// }
+
+ uccfa.setUsername(System.getProperty("user.name"));