You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2007/08/29 04:22:43 UTC

svn commit: r570608 - /openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/security/SecurityServiceImpl.java

Author: dblevins
Date: Tue Aug 28 19:22:43 2007
New Revision: 570608

URL: http://svn.apache.org/viewvc?rev=570608&view=rev
Log:
It's valid for the java.security.auth.login.config property to point to a URL, no need to try and convert it to a file path (which it may not be).

Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/security/SecurityServiceImpl.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/security/SecurityServiceImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/security/SecurityServiceImpl.java?rev=570608&r1=570607&r2=570608&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/security/SecurityServiceImpl.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/security/SecurityServiceImpl.java Tue Aug 28 19:22:43 2007
@@ -101,18 +101,23 @@
     }
 
     public Object login(String realmName, String username, String password) throws LoginException {
-        if (realmName == null){
-            realmName = this.realmName;
-        }
-        LoginContext context = new LoginContext(realmName, new UsernamePasswordCallbackHandler(username, password));
-        context.login();
+        try {
+            if (realmName == null){
+                realmName = this.realmName;
+            }
+            LoginContext context = new LoginContext(realmName, new UsernamePasswordCallbackHandler(username, password));
+            context.login();
 
-        Subject subject = context.getSubject();
+            Subject subject = context.getSubject();
 
-        Identity identity = new Identity(subject);
-        Serializable token = identity.getToken();
-        identities.put(token, identity);
-        return token;
+            Identity identity = new Identity(subject);
+            Serializable token = identity.getToken();
+            identities.put(token, identity);
+            return token;
+        } catch (LoginException e) {
+            e.printStackTrace();
+            throw e;
+        }
     }
 
     private final static class SecurityContext {
@@ -285,9 +290,7 @@
 
         URL loginConfig = ConfUtils.getConfResource("login.config");
 
-        path = loginConfig.getFile();
-        
-        System.setProperty("java.security.auth.login.config", path);
+        System.setProperty("java.security.auth.login.config", loginConfig.toExternalForm());
     }
 
     private static void installJacc() {