]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.cms/src/org/argeo/cms/internal/kernel/NodeSecurity.java
Introduce Single User login
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / internal / kernel / NodeSecurity.java
index d0aec2023cbcaccbf32eca9594d00dfec0d77d0c..f279ba5eab329d02ed5010ee2a848475c2d3b47d 100644 (file)
@@ -8,12 +8,13 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.cms.CmsException;
 import org.argeo.cms.internal.useradmin.JcrUserAdmin;
-import org.argeo.security.SecurityUtils;
+import org.argeo.cms.internal.useradmin.SimpleJcrSecurityModel;
+import org.argeo.cms.internal.useradmin.jackrabbit.JackrabbitUserAdminService;
+import org.argeo.security.OsAuthenticationToken;
 import org.argeo.security.UserAdminService;
 import org.argeo.security.core.InternalAuthentication;
 import org.argeo.security.core.InternalAuthenticationProvider;
-import org.argeo.security.jcr.SimpleJcrSecurityModel;
-import org.argeo.security.jcr.jackrabbit.JackrabbitUserAdminService;
+import org.argeo.security.core.OsAuthenticationProvider;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.useradmin.UserAdmin;
@@ -31,6 +32,7 @@ class NodeSecurity implements AuthenticationManager {
 
        private final BundleContext bundleContext;
 
+       private final OsAuthenticationProvider osAuth;
        private final InternalAuthenticationProvider internalAuth;
        private final AnonymousAuthenticationProvider anonymousAuth;
        private final JackrabbitUserAdminService userAdminService;
@@ -51,10 +53,11 @@ class NodeSecurity implements AuthenticationManager {
 
                this.bundleContext = bundleContext;
 
+               osAuth = new OsAuthenticationProvider();
                internalAuth = new InternalAuthenticationProvider(
-                               SecurityUtils.getStaticKey());
+                               Activator.getSystemKey());
                anonymousAuth = new AnonymousAuthenticationProvider(
-                               SecurityUtils.getStaticKey());
+                               Activator.getSystemKey());
 
                // user admin
                userAdminService = new JackrabbitUserAdminService();
@@ -86,6 +89,8 @@ class NodeSecurity implements AuthenticationManager {
                userDetailsManagerReg.unregister();
                userAdminServiceReg.unregister();
                authenticationManagerReg.unregister();
+
+               userAdmin.destroy();
                userAdminReg.unregister();
        }
 
@@ -99,6 +104,8 @@ class NodeSecurity implements AuthenticationManager {
                        auth = anonymousAuth.authenticate(authentication);
                else if (authentication instanceof UsernamePasswordAuthenticationToken)
                        auth = userAdminService.authenticate(authentication);
+               else if (authentication instanceof OsAuthenticationToken)
+                       auth = osAuth.authenticate(authentication);
                if (auth == null)
                        throw new CmsException("Could not authenticate " + authentication);
                return auth;