X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2FCmsLogin.java;h=a9dd8255f4e572e772b65fbb317ddf4827ff3b9b;hb=72db84d77477228eb752e9e6bd6f8ea6edaa6421;hp=eab83ee316113f6cdce0a36126cca7edfd193d84;hpb=0aace113e5cd3c265f2a1c7aeec5bac565fe581a;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/CmsLogin.java b/org.argeo.cms/src/org/argeo/cms/CmsLogin.java index eab83ee31..a9dd8255f 100644 --- a/org.argeo.cms/src/org/argeo/cms/CmsLogin.java +++ b/org.argeo.cms/src/org/argeo/cms/CmsLogin.java @@ -1,57 +1,49 @@ package org.argeo.cms; -import javax.security.auth.Subject; -import javax.security.auth.login.LoginContext; -import javax.security.auth.login.LoginException; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.argeo.ArgeoException; import org.argeo.cms.auth.ArgeoLoginContext; -import org.argeo.security.NodeAuthenticationToken; import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -/** Gateway for user login, can also generate the related UI. */ +/** + * Gateway for user login, can also generate the related UI. + * + * @deprecated Use {@link ArgeoLoginContext} instead + */ +@Deprecated public class CmsLogin { private final static Log log = LogFactory.getLog(CmsLogin.class); - private AuthenticationManager authenticationManager; - - // private String systemKey = KernelConstants.DEFAULT_SECURITY_KEY; - public void logInAsAnonymous() { - Subject subject = new Subject(); - final LoginContext loginContext; - try { - loginContext = new ArgeoLoginContext( - KernelHeader.LOGIN_CONTEXT_ANONYMOUS, subject); - loginContext.login(); - } catch (LoginException e1) { - throw new ArgeoException("Cannot authenticate anonymous", e1); - } - } - - public void logInWithPassword(String username, char[] password) { - NodeAuthenticationToken token = new NodeAuthenticationToken(username, - password); - Authentication authentication = authenticationManager - .authenticate(token); - SecurityContextHolder.getContext().setAuthentication(authentication); - // HttpSession httpSession = RWT.getRequest().getSession(); - // httpSession.setAttribute(SPRING_SECURITY_CONTEXT_KEY, - // SecurityContextHolder.getContext()); - if (log.isDebugEnabled()) - log.debug("Authenticated as " + authentication); + public CmsLogin() { + log.warn("org.argeo.cms.CmsLogin is deprecated and will be removed soon."); } + // private AuthenticationManager authenticationManager; + // + // public void logInAsAnonymous() { + // Subject subject = new Subject(); + // final LoginContext loginContext; + // try { + // loginContext = new ArgeoLoginContext( + // KernelHeader.LOGIN_CONTEXT_ANONYMOUS, subject); + // loginContext.login(); + // } catch (LoginException e1) { + // throw new ArgeoException("Cannot authenticate anonymous", e1); + // } + // } + // + // public void logInWithPassword(String username, char[] password) { + // NodeAuthenticationToken token = new NodeAuthenticationToken(username, + // password); + // Authentication authentication = authenticationManager + // .authenticate(token); + // SecurityContextHolder.getContext().setAuthentication(authentication); + // if (log.isDebugEnabled()) + // log.debug("Authenticated as " + authentication); + // } + // public void setAuthenticationManager( AuthenticationManager authenticationManager) { - this.authenticationManager = authenticationManager; + // this.authenticationManager = authenticationManager; } - - // public void setSystemKey(String systemKey) { - // this.systemKey = systemKey; - // } - }