Coverage Report - org.acegisecurity.providers.rcp.RemoteAuthenticationManagerImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
RemoteAuthenticationManagerImpl
100% 
N/A 
1.75
 
 1  
 /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
 2  
  *
 3  
  * Licensed under the Apache License, Version 2.0 (the "License");
 4  
  * you may not use this file except in compliance with the License.
 5  
  * You may obtain a copy of the License at
 6  
  *
 7  
  *     http://www.apache.org/licenses/LICENSE-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing, software
 10  
  * distributed under the License is distributed on an "AS IS" BASIS,
 11  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
  * See the License for the specific language governing permissions and
 13  
  * limitations under the License.
 14  
  */
 15  
 
 16  
 package org.acegisecurity.providers.rcp;
 17  
 
 18  
 import org.acegisecurity.AuthenticationException;
 19  
 import org.acegisecurity.AuthenticationManager;
 20  
 import org.acegisecurity.GrantedAuthority;
 21  
 
 22  
 import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
 23  
 
 24  
 import org.springframework.beans.factory.InitializingBean;
 25  
 
 26  
 import org.springframework.util.Assert;
 27  
 
 28  
 
 29  
 /**
 30  
  * Server-side processor of a remote authentication request.<P>This bean requires no security interceptor to
 31  
  * protect it. Instead, the bean uses the configured <code>AuthenticationManager</code> to resolve an authentication
 32  
  * request.</p>
 33  
  *
 34  
  * @author Ben Alex
 35  
  * @version $Id: RemoteAuthenticationManagerImpl.java 1496 2006-05-23 13:38:33Z benalex $
 36  
  */
 37  4
 public class RemoteAuthenticationManagerImpl implements RemoteAuthenticationManager, InitializingBean {
 38  
     //~ Instance fields ================================================================================================
 39  
 
 40  
     private AuthenticationManager authenticationManager;
 41  
 
 42  
     //~ Methods ========================================================================================================
 43  
 
 44  
     public void afterPropertiesSet() throws Exception {
 45  2
         Assert.notNull(this.authenticationManager, "authenticationManager is required");
 46  1
     }
 47  
 
 48  
     public GrantedAuthority[] attemptAuthentication(String username, String password)
 49  
         throws RemoteAuthenticationException {
 50  2
         UsernamePasswordAuthenticationToken request = new UsernamePasswordAuthenticationToken(username, password);
 51  
 
 52  
         try {
 53  2
             return authenticationManager.authenticate(request).getAuthorities();
 54  1
         } catch (AuthenticationException authEx) {
 55  1
             throw new RemoteAuthenticationException(authEx.getMessage());
 56  
         }
 57  
     }
 58  
 
 59  
     public AuthenticationManager getAuthenticationManager() {
 60  1
         return authenticationManager;
 61  
     }
 62  
 
 63  
     public void setAuthenticationManager(AuthenticationManager authenticationManager) {
 64  4
         this.authenticationManager = authenticationManager;
 65  4
     }
 66  
 }