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