Clover Coverage Report - itracker
Coverage timestamp: Tue May 1 2012 16:42:12 CEST
13   90   10   4.33
10   35   0.77   3
3     3.33  
1    
 
 
  AbstractPluggableAuthenticator       Line # 35 13 10 0% 0.0
 
No Tests
 
1    /*
2    * This software was designed and created by Jason Carroll.
3    * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4    * The author can be reached at jcarroll@cowsultants.com
5    * ITracker website: http://www.cowsultants.com
6    * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7    *
8    * This program is free software; you can redistribute it and/or modify
9    * it only under the terms of the GNU General Public License as published by
10    * the Free Software Foundation; either version 2 of the License, or
11    * (at your option) any later version.
12    *
13    * This program is distributed in the hope that it will be useful,
14    * but WITHOUT ANY WARRANTY; without even the implied warranty of
15    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16    * GNU General Public License for more details.
17    */
18   
19    package org.itracker.services.authentication;
20   
21    import java.util.Map;
22   
23    import org.itracker.services.ConfigurationService;
24    import org.itracker.services.UserService;
25    import org.itracker.services.exceptions.AuthenticatorException;
26    import org.itracker.services.util.AuthenticationConstants;
27   
28    // TODO: Rewrite Javadocs here: we don't have session beans or EJBs anymore
29   
30    /**
31    * This class provides a skeleton implementation of the PluggableAuthenticator interface.
32    * It can be extended to provide a new authentication module for ITracker reducing the amount
33    * of effort to implement the PluggableAuthenticator interface.
34    */
 
35    public abstract class AbstractPluggableAuthenticator
36    implements PluggableAuthenticator, AuthenticationConstants {
37   
38    // private final Logger logger;
39    private UserService userService = null;
40    private ConfigurationService configurationService = null;
41   
42   
43    /**
44    * This method is called after creating a new instance of the Authenticator. It supplies
45    * some default EJB objects that the authenticator can use.
46    */
 
47  0 toggle public void initialize(Map<?, ?> values) {
48  0 if(values != null) {
49  0 Object userService = values.get("userService");
50  0 Object configurationService = values.get("configurationService");
51   
52  0 if(userService instanceof UserService) {
53  0 this.userService = (UserService) userService;
54    }
55  0 if(configurationService instanceof ConfigurationService) {
56  0 this.configurationService = (ConfigurationService) configurationService;
57    }
58    }
59    }
60   
61    /**
62    * Returns a UserService session bean that can be used to call needed methods such
63    * as retrieving a user.
64    * @return userService
65    * @throws AuthenticatorException an exception if an error occur
66    */
 
67  0 toggle public UserService getUserService() throws AuthenticatorException {
68  0 if(userService == null || ! (userService instanceof UserService)) {
69  0 throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR);
70    }
71   
72  0 return userService;
73    }
74   
75    /**
76    * Returns an ConfigurationService session bean that can be used to retreive properties
77    * that have been set in the system. These properties can be used to provide any
78    * needed configuration for the authenticator.
79    * @return configurationService
80    * @throws AuthenticatorException an exception if an error occur
81    */
 
82  0 toggle public ConfigurationService getConfigurationService() throws AuthenticatorException {
83  0 if(configurationService == null || ! (configurationService instanceof ConfigurationService)) {
84  0 throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR);
85    }
86   
87  0 return configurationService;
88    }
89   
90    }