diff --git a/sandbox/other/src/main/java/org/acegisecurity/providers/smb/AbstractSmbAuthenticationProvider.java b/sandbox/other/src/main/java/org/acegisecurity/providers/smb/AbstractSmbAuthenticationProvider.java deleted file mode 100644 index 82ab5c2515..0000000000 --- a/sandbox/other/src/main/java/org/acegisecurity/providers/smb/AbstractSmbAuthenticationProvider.java +++ /dev/null @@ -1,110 +0,0 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.acegisecurity.providers.smb; - -import jcifs.UniAddress; - -import jcifs.smb.NtlmPasswordAuthentication; -import jcifs.smb.SmbAuthException; -import jcifs.smb.SmbException; -import jcifs.smb.SmbSession; - -import org.acegisecurity.Authentication; -import org.acegisecurity.AuthenticationException; -import org.acegisecurity.AuthenticationServiceException; -import org.acegisecurity.BadCredentialsException; - -import org.acegisecurity.providers.AuthenticationProvider; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - - -/** - * An {@link AuthenticationProvider} implementation that relies on jcifs in - * order to provide an authentication service on a Windows network. This implementation relies on a {@link - * #setAuthorizationProvider(AuthenticationProvider) delegate provider} in order for authorization information to be - * filled into the authorized {@link Authentication token}. Subclasses must implement the logic that {@link - * #getNtlmPasswordAuthentication(Authentication) extracts the jcifs }{@link NtlmPasswordAuthentication } object from - * the particular {@link Authentication } token implementation and the one that {@link - * #getDomainController(Authentication, NtlmPasswordAuthentication) extracts the domain controller address }. - * - * @author Davide Baroncelli - * @version $Id$ - */ -public abstract class AbstractSmbAuthenticationProvider implements AuthenticationProvider { - //~ Instance fields ================================================================================================ - - private AuthenticationProvider authorizationProvider; - private Log log = LogFactory.getLog(this.getClass()); - - //~ Methods ======================================================================================================== - - public Authentication authenticate(Authentication authentication) - throws AuthenticationException { - NtlmPasswordAuthentication ntlm = getNtlmPasswordAuthentication(authentication); - UniAddress dc = getDomainController(authentication, ntlm); - - return performAuthentication(dc, ntlm, authentication); - } - - protected abstract UniAddress getDomainController(Authentication authentication, - NtlmPasswordAuthentication ntlmAuthentication); - - protected abstract NtlmPasswordAuthentication getNtlmPasswordAuthentication(Authentication authentication); - - protected Authentication performAuthentication(UniAddress dc, NtlmPasswordAuthentication ntlm, - Authentication authentication) { - try { - // this performs authentication... - SmbSession.logon(dc, ntlm); - - if (log.isDebugEnabled()) { - log.debug(ntlm + " successfully authenticated against " + dc); - } - - // ...and this performs authorization. - Authentication authorizedResult = authorizationProvider.authenticate(authentication); - - return authorizedResult; - } catch (SmbException se) { - log.error(ntlm.getName() + ": 0x" + jcifs.util.Hexdump.toHexString(se.getNtStatus(), 8) + ": " + se); - - if (se instanceof SmbAuthException) { - SmbAuthException sae = (SmbAuthException) se; - - if (se.getNtStatus() == SmbAuthException.NT_STATUS_ACCESS_VIOLATION) { - throw new ChallengeExpiredException(sae.getMessage(), sae); - } else { - throw new BadCredentialsException(sae.getMessage(), sae); - } - } else { - throw new AuthenticationServiceException(se.getMessage(), se); - } - } - } - - /** - * DOCUMENT ME! - * - * @param authorizationProvider The {@link AuthenticationProvider } which will be contacted in order for it to fill - * authorization info in the (already authenticated) {@link Authentication } object that they will be - * passed. - */ - public void setAuthorizationProvider(AuthenticationProvider authorizationProvider) { - this.authorizationProvider = authorizationProvider; - } -} diff --git a/sandbox/other/src/main/java/org/acegisecurity/providers/smb/ChallengeExpiredException.java b/sandbox/other/src/main/java/org/acegisecurity/providers/smb/ChallengeExpiredException.java deleted file mode 100644 index 96392860fe..0000000000 --- a/sandbox/other/src/main/java/org/acegisecurity/providers/smb/ChallengeExpiredException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.acegisecurity.providers.smb; - -import org.acegisecurity.AuthenticationException; - - -/** - * Thrown if - * - * @author Davide Baroncelli - * @version $Id$ - */ -public class ChallengeExpiredException extends AuthenticationException { - //~ Constructors =================================================================================================== - - public ChallengeExpiredException(String msg) { - super(msg); - } - - public ChallengeExpiredException(String msg, Throwable t) { - super(msg, t); - } -} diff --git a/sandbox/other/src/main/java/org/acegisecurity/providers/smb/NtlmAuthenticationToken.java b/sandbox/other/src/main/java/org/acegisecurity/providers/smb/NtlmAuthenticationToken.java deleted file mode 100644 index 9962bf3a77..0000000000 --- a/sandbox/other/src/main/java/org/acegisecurity/providers/smb/NtlmAuthenticationToken.java +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.acegisecurity.providers.smb; - -import jcifs.UniAddress; - -import jcifs.smb.NtlmPasswordAuthentication; - -import org.acegisecurity.Authentication; - -import org.acegisecurity.providers.AbstractAuthenticationToken; - - -/** - * {@link Authentication } implementation for NTLM smb authentication. - * - * @author Davide Baroncelli - * @version $Id$ - * - * @see org.acegisecurity.ui.ntlm.NtlmProcessingFilter - * @see org.acegisecurity.providers.smb.SmbNtlmAuthenticationProvider - */ -public class NtlmAuthenticationToken extends AbstractAuthenticationToken { - //~ Instance fields ================================================================================================ - - private NtlmPasswordAuthentication ntlmPasswordAuthentication; - private transient UniAddress domainController; - - //~ Constructors =================================================================================================== - - public NtlmAuthenticationToken(NtlmPasswordAuthentication ntlmPasswordAuthentication, UniAddress domainController) { - super(null); - this.ntlmPasswordAuthentication = ntlmPasswordAuthentication; - this.domainController = domainController; - } - - //~ Methods ======================================================================================================== - - public Object getCredentials() { - return ntlmPasswordAuthentication.getPassword(); - } - - public UniAddress getDomainController() { - return domainController; - } - - public NtlmPasswordAuthentication getNtlmPasswordAuthentication() { - return ntlmPasswordAuthentication; - } - - public Object getPrincipal() { - return ntlmPasswordAuthentication.getUsername(); - } -} diff --git a/sandbox/other/src/main/java/org/acegisecurity/providers/smb/SmbBasicAuthenticationProvider.java b/sandbox/other/src/main/java/org/acegisecurity/providers/smb/SmbBasicAuthenticationProvider.java deleted file mode 100644 index 3e1ae79b03..0000000000 --- a/sandbox/other/src/main/java/org/acegisecurity/providers/smb/SmbBasicAuthenticationProvider.java +++ /dev/null @@ -1,93 +0,0 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.acegisecurity.providers.smb; - -import jcifs.Config; -import jcifs.UniAddress; - -import jcifs.smb.NtlmPasswordAuthentication; - -import org.acegisecurity.Authentication; -import org.acegisecurity.BadCredentialsException; - -import org.acegisecurity.providers.UsernamePasswordAuthenticationToken; - -import java.net.UnknownHostException; - - -/** - * Provides authentication of a basic {@link UsernamePasswordAuthenticationToken } on a ntlm domain via smb/cifs. - * - * @author Davide Baroncelli - * @version $Id$ - */ -public class SmbBasicAuthenticationProvider extends AbstractSmbAuthenticationProvider { - //~ Instance fields ================================================================================================ - - String domainController; - - //~ Methods ======================================================================================================== - - protected UniAddress getDomainController(Authentication authentication, - NtlmPasswordAuthentication ntlmAuthentication) { - try { - if (domainController == null) { - domainController = Config.getProperty("jcifs.smb.client.domain"); - } - - String domain = domainController; - - if (domain == null) { - domain = ntlmAuthentication.getDomain(); - } - - UniAddress dc = UniAddress.getByName(domain, true); - - return dc; - } catch (UnknownHostException uhe) { - throw new BadCredentialsException("no host could be found for the name " + ntlmAuthentication.getDomain(), - uhe); - } - } - - protected NtlmPasswordAuthentication getNtlmPasswordAuthentication(Authentication authentication) { - UsernamePasswordAuthenticationToken token = (UsernamePasswordAuthenticationToken) authentication; - String username = token.getPrincipal().toString(); - String password = (String) token.getCredentials(); - int index = username.indexOf('\\'); - - if (index == -1) { - index = username.indexOf('/'); - } - - // if domain is null then the jcifs default is used - // (this is set through the "jcifs.smb.client.domain" Config property) - String domain = (index != -1) ? username.substring(0, index) : null; - username = (index != -1) ? username.substring(index + 1) : username; - - NtlmPasswordAuthentication ntlm = new NtlmPasswordAuthentication(domain, username, password); - - return ntlm; - } - - public void setDomainController(String domainController) { - this.domainController = domainController; - } - - public boolean supports(Class authentication) { - return UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication); - } -} diff --git a/sandbox/other/src/main/java/org/acegisecurity/providers/smb/SmbNtlmAuthenticationProvider.java b/sandbox/other/src/main/java/org/acegisecurity/providers/smb/SmbNtlmAuthenticationProvider.java deleted file mode 100644 index aa33f4a686..0000000000 --- a/sandbox/other/src/main/java/org/acegisecurity/providers/smb/SmbNtlmAuthenticationProvider.java +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.acegisecurity.providers.smb; - -import jcifs.UniAddress; - -import jcifs.smb.NtlmPasswordAuthentication; - -import org.acegisecurity.Authentication; - -import org.acegisecurity.ui.ntlm.NtlmProcessingFilter; - - -/** - * This class provides authentication through smb of {@link NtlmAuthenticationToken } (i.e. tokens obtained through - * the NTLM Authorization method by {@link NtlmProcessingFilter } ). - * - * @author Davide Baroncelli - * @version $Id$ - * - * @see org.acegisecurity.ui.ntlm.NtlmProcessingFilter - */ -public class SmbNtlmAuthenticationProvider extends AbstractSmbAuthenticationProvider { - //~ Methods ======================================================================================================== - - protected UniAddress getDomainController(Authentication authentication, - NtlmPasswordAuthentication ntlmAuthentication) { - NtlmAuthenticationToken ntlmToken = (NtlmAuthenticationToken) authentication; - UniAddress dc = ntlmToken.getDomainController(); - - return dc; - } - - protected NtlmPasswordAuthentication getNtlmPasswordAuthentication(Authentication authentication) { - NtlmAuthenticationToken ntlmToken = (NtlmAuthenticationToken) authentication; - NtlmPasswordAuthentication ntlm = ntlmToken.getNtlmPasswordAuthentication(); - - return ntlm; - } - - public boolean supports(Class authentication) { - return NtlmAuthenticationToken.class.isAssignableFrom(authentication); - } -} diff --git a/sandbox/other/src/main/java/org/acegisecurity/ui/ntlm/NtlmProcessingFilter.java b/sandbox/other/src/main/java/org/acegisecurity/ui/ntlm/NtlmProcessingFilter.java deleted file mode 100644 index 1ae415542b..0000000000 --- a/sandbox/other/src/main/java/org/acegisecurity/ui/ntlm/NtlmProcessingFilter.java +++ /dev/null @@ -1,287 +0,0 @@ -/* - * LICENSE IS UNKNOWN (SEE TODO COMMENT LATER IN SOURCE CODE) - */ -package org.acegisecurity.ui.ntlm; - -import jcifs.Config; -import jcifs.UniAddress; - -import jcifs.http.NtlmSsp; - -import jcifs.smb.NtlmChallenge; -import jcifs.smb.NtlmPasswordAuthentication; -import jcifs.smb.SmbSession; - -import org.acegisecurity.Authentication; -import org.acegisecurity.AuthenticationException; -import org.acegisecurity.AuthenticationManager; -import org.acegisecurity.BadCredentialsException; -import org.acegisecurity.context.SecurityContextHolder; -import org.acegisecurity.providers.smb.NtlmAuthenticationToken; -import org.acegisecurity.ui.AuthenticationEntryPoint; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.factory.InitializingBean; - -import org.springframework.util.Assert; - -import java.io.IOException; - -import java.util.Iterator; -import java.util.Properties; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - - -/** - * A reimplementation of the jcifs NtlmHttpFilter suitable for use with the - * Acegi Security System. - * - *
- * This servlet Filter can be used to negotiate password hashes with MSIE
- * clients using NTLM SSP. This is similar to Authentication:
- * BASIC but weakly encrypted and without requiring the user to
- * re-supply authentication credentials.
- *