Browse Source
MockAuthenticationManager was the only other subclass (apart from the main ProviderManager) and has been removed also.pull/1/head
6 changed files with 60 additions and 165 deletions
@ -1,84 +0,0 @@
@@ -1,84 +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.springframework.security.authentication; |
||||
|
||||
import org.springframework.security.core.Authentication; |
||||
import org.springframework.security.core.AuthenticationException; |
||||
|
||||
/** |
||||
* An abstract implementation of the {@link AuthenticationManager}. |
||||
* |
||||
* @author Wesley Hall |
||||
*/ |
||||
public abstract class AbstractAuthenticationManager implements AuthenticationManager { |
||||
|
||||
//~ Instance fields ================================================================================================
|
||||
private boolean clearExtraInformation = false; |
||||
|
||||
//~ Methods ========================================================================================================
|
||||
|
||||
/** |
||||
* An implementation of the <code>authenticate</code> method that calls the abstract method |
||||
* <code>doAuthenticatation</code> to do its work. |
||||
* <p> |
||||
* If doAuthenticate throws an <code>AuthenticationException</code> then the exception is populated |
||||
* with the failed <code>Authentication</code> object that failed. |
||||
* |
||||
* @param authRequest the authentication request object |
||||
* |
||||
* @return a fully authenticated object including credentials |
||||
* |
||||
* @throws AuthenticationException if authentication fails |
||||
*/ |
||||
public final Authentication authenticate(Authentication authRequest) throws AuthenticationException { |
||||
try { |
||||
return doAuthentication(authRequest); |
||||
} catch (AuthenticationException e) { |
||||
e.setAuthentication(authRequest); |
||||
|
||||
if (clearExtraInformation) { |
||||
e.clearExtraInformation(); |
||||
} |
||||
|
||||
throw e; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Concrete implementations of this class override this method to provide the authentication service. |
||||
* <p> |
||||
* The contract for this method is documented in the |
||||
* {@link AuthenticationManager#authenticate(Authentication)}. |
||||
* |
||||
* @param authentication the authentication request object |
||||
* |
||||
* @return a fully authenticated object including credentials |
||||
* |
||||
* @throws AuthenticationException if authentication fails |
||||
*/ |
||||
protected abstract Authentication doAuthentication(Authentication authentication) throws AuthenticationException; |
||||
|
||||
/** |
||||
* If set to true, the <tt>extraInformation</tt> set on an <tt>AuthenticationException</tt> will be cleared |
||||
* before rethrowing it. This is useful for use with remoting protocols where the information shouldn't |
||||
* be serialized to the client. Defaults to 'false'. |
||||
* |
||||
* @see org.springframework.security.core.AuthenticationException#getExtraInformation() |
||||
*/ |
||||
public void setClearExtraInformation(boolean clearExtraInformation) { |
||||
this.clearExtraInformation = clearExtraInformation; |
||||
} |
||||
} |
||||
@ -1,52 +0,0 @@
@@ -1,52 +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.springframework.security; |
||||
|
||||
import org.springframework.security.authentication.AbstractAuthenticationManager; |
||||
import org.springframework.security.authentication.BadCredentialsException; |
||||
import org.springframework.security.core.Authentication; |
||||
import org.springframework.security.core.AuthenticationException; |
||||
|
||||
/** |
||||
* Simply accepts as valid whatever is passed to it, if <code>grantAccess</code> is set to <code>true</code>. |
||||
* |
||||
* @author Ben Alex |
||||
* @author Wesley Hall |
||||
*/ |
||||
public class MockAuthenticationManager extends AbstractAuthenticationManager { |
||||
//~ Instance fields ================================================================================================
|
||||
|
||||
private boolean grantAccess = true; |
||||
|
||||
//~ Constructors ===================================================================================================
|
||||
|
||||
public MockAuthenticationManager(boolean grantAccess) { |
||||
this.grantAccess = grantAccess; |
||||
} |
||||
|
||||
public MockAuthenticationManager() { |
||||
} |
||||
|
||||
//~ Methods ========================================================================================================
|
||||
|
||||
public Authentication doAuthentication(Authentication authentication) throws AuthenticationException { |
||||
if (grantAccess) { |
||||
return authentication; |
||||
} else { |
||||
throw new BadCredentialsException("MockAuthenticationManager instructed to deny access"); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue