View Javadoc

1   /**
2    * Originally contributed by eMation (www.emation.pt)
3    */
4   package org.itracker.services.authentication.adsson;
5   
6   import java.io.IOException;
7   
8   import javax.security.auth.login.LoginException;
9   
10  import org.apache.log4j.Logger;
11  import org.itracker.model.User;
12  import org.itracker.services.exceptions.AuthenticatorException;
13  
14  /**
15   * Extends the windows single sign on class, gets user information
16   * from active directory
17   *
18   * @author ricardo
19   */
20  public class WindowsSSONAuthenticatorADInfo extends WindowsSSONAuthenticator {
21      private static final Logger logger = Logger.getLogger(WindowsSSONAuthenticatorADInfo.class);
22      /**
23       *
24       * @see com.emation.itracker.authentication.WindowsSSONAuthenticator#getExternalUserInfo(java.lang.String)
25       */
26      protected User getExternalUserInfo(String login) throws AuthenticatorException {
27          try {
28              // connect to active directory
29              ADIntegration ad = new ADIntegration();
30              ad.login();
31              // get external user info
32              User userModel = (User)ad.getUserInfo( login );
33              return userModel;
34          } catch (LoginException e) {
35              logger.error("getExternalUserInfo: " + e.getMessage() + AuthenticatorException.SYSTEM_ERROR );
36              throw new AuthenticatorException( "Error accessing Active Directory: " + e.getMessage(), AuthenticatorException.SYSTEM_ERROR, e);
37          } catch (IOException e) {
38              logger.error( e.getMessage() );
39              throw new AuthenticatorException( e.getMessage(), AuthenticatorException.SYSTEM_ERROR);
40          }
41      }
42      
43  }