private static Object instance = null;
private static final Object locker = new Object();
- private Traitement traitement;
+ private final Traitement traitement;
private Hashtable adEnvConf;
/**
* @param args
*/
- public ActiveDirectorySynchronizer(String[] args) {
+ public ActiveDirectorySynchronizer(final String[] args) {
super(args);
- traitement = new Traitement(ActiveDirectorySynchronizer.class, BATCH_NAME);
+ this.traitement = new Traitement(ActiveDirectorySynchronizer.class, BATCH_NAME);
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void initialize() throws Exception {
- String adURL = getProps().getProperty(AD_URL_PROP);
- String adUser = getProps().getProperty(AD_USERNAME_PROP);
- String adPassword = Scramble.unScramblePassword(getProps().getProperty(AD_PASSWORD_PROP));
- String adResultPageSize = getProps().getProperty(AD_RESULT_PAGE_SIZE_PROP);
- String adFullSync = getProps().getProperty(SYNC_FULL_PROP);
+ final String adURL = this.getProps().getProperty(AD_URL_PROP);
+ final String adUser = this.getProps().getProperty(AD_USERNAME_PROP);
+ final String adPassword = Scramble.unScramblePassword(this.getProps().getProperty(AD_PASSWORD_PROP));
+ final String adResultPageSize = this.getProps().getProperty(AD_RESULT_PAGE_SIZE_PROP);
+ final String adFullSync = this.getProps().getProperty(SYNC_FULL_PROP);
- adBaseDn = getProps().getProperty(AD_BASE_DN_PROP);
- resultPageSize = (StringUtils.isEmpty(adResultPageSize) ? 100 : Integer.parseInt(adResultPageSize));
- fullSync = (StringUtils.isEmpty(adFullSync) ? false : Boolean.valueOf(adFullSync));
+ this.adBaseDn = this.getProps().getProperty(AD_BASE_DN_PROP);
+ this.resultPageSize = (StringUtils.isEmpty(adResultPageSize) ? 100 : Integer.parseInt(adResultPageSize));
+ this.fullSync = (StringUtils.isEmpty(adFullSync) ? false : Boolean.valueOf(adFullSync));
logger.debug("LDAP - url=" + adURL + " - user=" + adUser);
- adEnvConf = new Hashtable();
- adEnvConf.put(Context.INITIAL_CONTEXT_FACTORY, AD_LDAP_CONTEXT_FACTORY);
- adEnvConf.put(Context.PROVIDER_URL, adURL);
- adEnvConf.put(Context.SECURITY_AUTHENTICATION, AD_LDAP_SECURITY_AUTHENTICATION);
- adEnvConf.put(Context.SECURITY_PRINCIPAL, adUser);
- adEnvConf.put(Context.SECURITY_CREDENTIALS, adPassword);
- adEnvConf.put(Context.REFERRAL, "follow");
+ this.adEnvConf = new Hashtable();
+ this.adEnvConf.put(Context.INITIAL_CONTEXT_FACTORY, AD_LDAP_CONTEXT_FACTORY);
+ this.adEnvConf.put(Context.PROVIDER_URL, adURL);
+ this.adEnvConf.put(Context.SECURITY_AUTHENTICATION, AD_LDAP_SECURITY_AUTHENTICATION);
+ this.adEnvConf.put(Context.SECURITY_PRINCIPAL, adUser);
+ this.adEnvConf.put(Context.SECURITY_CREDENTIALS, adPassword);
+ this.adEnvConf.put(Context.REFERRAL, "follow");
logger.debug("Test d'initialisation du DirContext AD");
- InitialLdapContext adContext = new InitialLdapContext(adEnvConf, null);
+ final InitialLdapContext adContext = new InitialLdapContext(this.adEnvConf, null);
adContext.close();
logger.debug("Construction des filtres");
- DataImpl dataLayer = DataLayerManager.getImplementation();
- mainAdminDn = dataLayer.getParameterValue(PARAMETER_AD_MAIN_ADMIN_DN);
- delegAdminDn = dataLayer.getParameterValue(PARAMETER_AD_DELEGATED_ADMIN_DN);
- userDn = dataLayer.getParameterValue(PARAMETER_AD_USER_DN);
+ final DataImpl dataLayer = DataLayerManager.getImplementation();
+ this.mainAdminDn = dataLayer.getParameterValue(PARAMETER_AD_MAIN_ADMIN_DN);
+ this.delegAdminDn = dataLayer.getParameterValue(PARAMETER_AD_DELEGATED_ADMIN_DN);
+ this.userDn = dataLayer.getParameterValue(PARAMETER_AD_USER_DN);
- ldapFilterAllUser = buildFilter(LDAP_FILTER_ALL_USER, mainAdminDn, delegAdminDn, userDn);
- ldapFilterAllUserFromLastSync = buildFilter(LDAP_FILTER_USER_FROM_LAST_SYNC, mainAdminDn, delegAdminDn, userDn);
- ldapFilterUserNotXemelios = buildFilter(LDAP_FILTER_USER_NOT_XEMELIOS, mainAdminDn, delegAdminDn, userDn);
+ this.ldapFilterAllUser = this.buildFilter(LDAP_FILTER_ALL_USER, this.mainAdminDn, this.delegAdminDn, this.userDn);
+ this.ldapFilterAllUserFromLastSync = this.buildFilter(LDAP_FILTER_USER_FROM_LAST_SYNC, this.mainAdminDn, this.delegAdminDn, this.userDn);
+ this.ldapFilterUserNotXemelios = this.buildFilter(LDAP_FILTER_USER_NOT_XEMELIOS, this.mainAdminDn, this.delegAdminDn, this.userDn);
logger.debug("Inistialisation du QueryProvider");
- String queryFileName = dataLayer.getLayerName() + "-queries.properties";
- queryProvider = new QueryProvider(this.getClass().getResource(queryFileName));
+ final String queryFileName = dataLayer.getLayerName() + "-queries.properties";
+ this.queryProvider = new QueryProvider(this.getClass().getResource(queryFileName));
}
@SuppressWarnings("rawtypes")
@Override
protected void doProcess() throws Exception {
- if (checkNotRunning()) {
- PoolManager pool = PoolManager.getInstance();
- Connection connection = pool.getConnection();
- LdapContext adContext = new InitialLdapContext(adEnvConf, null);
+ if (this.checkNotRunning()) {
+ final PoolManager pool = PoolManager.getInstance();
+ final Connection connection = pool.getConnection();
+ final LdapContext adContext = new InitialLdapContext(this.adEnvConf, null);
long newUserSyncCount = 0, updatedUserSyncCount = 0, noneUserSyncCount = 0, deletedUserSyncCount = 0;
long startTime, endTime;
try {
- DataImpl dataLayer = DataLayerManager.getImplementation();
- String lastSyncDtFmt = dataLayer.getParameterValue(PARAMETER_AD_LAST_SYNC);
+ final DataImpl dataLayer = DataLayerManager.getImplementation();
+ final String lastSyncDtFmt = dataLayer.getParameterValue(PARAMETER_AD_LAST_SYNC);
NamingEnumeration usersToSynchronize;
- String filter = (lastSyncDtFmt == null || fullSync ? ldapFilterAllUser : ldapFilterAllUserFromLastSync);
- String adCurrentTime = getActiveDirectoryCurrentTime(adContext);
+ final String filter = (lastSyncDtFmt == null || this.fullSync ? this.ldapFilterAllUser : this.ldapFilterAllUserFromLastSync);
+ final String adCurrentTime = this.getActiveDirectoryCurrentTime(adContext);
logger.info("Dernière synchronisation LDAP effectuée le : " + lastSyncDtFmt);
connection.setAutoCommit(false);
- adContext.setRequestControls(new Control[] { new PagedResultsControl(resultPageSize, Control.CRITICAL) });
+ adContext.setRequestControls(new Control[] { new PagedResultsControl(this.resultPageSize, Control.CRITICAL) });
// -------- Traitement paginé des utilisateurs créés / mofifiés -------------
startTime = System.currentTimeMillis();
do {
- usersToSynchronize = getAdUsers(adContext, filter, lastSyncDtFmt);
+ usersToSynchronize = this.getAdUsers(adContext, filter, lastSyncDtFmt);
try {
while (usersToSynchronize != null && usersToSynchronize.hasMore()) {
- SearchResult adData = (SearchResult) usersToSynchronize.next();
- Attributes attributes = adData.getAttributes();
+ final SearchResult adData = (SearchResult) usersToSynchronize.next();
+ final Attributes attributes = adData.getAttributes();
if (attributes.get("userPrincipalName") == null) {
logger.warn("Utilisateur sans login ignoré [sync] : " + attributes.toString());
} else {
- ActiveDirectoryUser adUser = new ActiveDirectoryUser(attributes);
+ final ActiveDirectoryUser adUser = new ActiveDirectoryUser(attributes);
logger.debug("Synchronisation utilisateur : " + adUser.getLogin());
- switch (synchronizeUser(connection, adUser)) {
+ switch (this.synchronizeUser(connection, adUser)) {
case INSERT:
- updateUserProfiles(connection, adUser);
+ this.updateUserProfiles(connection, adUser);
newUserSyncCount++;
break;
case UPDATE:
- updateUserProfiles(connection, adUser);
+ this.updateUserProfiles(connection, adUser);
updatedUserSyncCount++;
break;
case NONE:
usersToSynchronize.close();
}
}
- } while (ldapNextPage(adContext));
+ } while (this.ldapNextPage(adContext));
// -------- Traitement paginé des utilisateurs supprimés des groupes xemelios -------------
do {
- usersToSynchronize = getAdUsers(adContext, ldapFilterUserNotXemelios, null);
+ usersToSynchronize = this.getAdUsers(adContext, this.ldapFilterUserNotXemelios, null);
try {
while (usersToSynchronize != null && usersToSynchronize.hasMore()) {
- SearchResult adData = (SearchResult) usersToSynchronize.next();
- Attributes attributes = adData.getAttributes();
+ final SearchResult adData = (SearchResult) usersToSynchronize.next();
+ final Attributes attributes = adData.getAttributes();
if (attributes.get("userPrincipalName") == null) {
logger.warn("Utilisateur sans login ignoré [unsync] : " + attributes.toString());
} else {
- ActiveDirectoryUser adUser = new ActiveDirectoryUser(attributes);
- Long userId = getUserIdFromGuid(connection, adUser.getGuid());
+ final ActiveDirectoryUser adUser = new ActiveDirectoryUser(attributes);
+ final Long userId = this.getUserIdFromGuid(connection, adUser.getGuid());
if (userId != null) {
- unsynchronizeUser(connection, userId);
+ this.unsynchronizeUser(connection, userId);
deletedUserSyncCount++;
}
}
usersToSynchronize.close();
}
}
- } while (ldapNextPage(adContext));
+ } while (this.ldapNextPage(adContext));
// on enregistre la date de synchronisation
- updateLastSyncParameter(adCurrentTime);
+ this.updateLastSyncParameter(adCurrentTime);
connection.commit();
endTime = System.currentTimeMillis();
// on calcul le périmètre d'action des utilisateurs
startTime = System.currentTimeMillis();
- buildUserScopes(connection);
+ this.buildUserScopes(connection);
connection.commit();
endTime = System.currentTimeMillis();
logger.info("Calcul des périmètres utilisateurs : " + String.format("%.2g", (endTime - startTime) / 1000.0) + " s");
- } catch (Throwable t) {
+ } catch (final Throwable t) {
logger.error("Synchonisation LDAP", t);
} finally {
logger.info("Fin de la synchronisation LDAP : " + newUserSyncCount + " utilisateurs créés, " + updatedUserSyncCount + " mis à jour, " + noneUserSyncCount + " non-synchronisés, " + deletedUserSyncCount + " supprimés");
- clearLock();
+ this.clearLock();
connection.rollback();
pool.releaseConnection(connection);
adContext.close();
}
} else {
- traitement.setResume("Dejà en cours d'execution");
+ this.traitement.setResume("Dejà en cours d'execution");
}
- traitement.setEnd(System.currentTimeMillis());
+ this.traitement.setEnd(System.currentTimeMillis());
}
- protected NamingEnumeration<?> getAdUsers(DirContext adContext, String filter, String syncDate) throws NamingException {
- SearchControls searchCtrl = new SearchControls();
+ protected NamingEnumeration<?> getAdUsers(final DirContext adContext, final String filter, final String syncDate) throws NamingException {
+ final SearchControls searchCtrl = new SearchControls();
searchCtrl.setSearchScope(SearchControls.SUBTREE_SCOPE);
- return adContext.search(adBaseDn, builFilter(filter, syncDate), searchCtrl);
+ return adContext.search(this.adBaseDn, this.builFilter(filter, syncDate), searchCtrl);
}
- protected boolean ldapNextPage(LdapContext adContext) throws NamingException, IOException {
+ protected boolean ldapNextPage(final LdapContext adContext) throws NamingException, IOException {
byte[] cookie = null;
- Control[] controls = adContext.getResponseControls();
+ final Control[] controls = adContext.getResponseControls();
if (controls != null) {
- for (int i = 0; i < controls.length; i++) {
- if (controls[i] instanceof PagedResultsResponseControl) {
- PagedResultsResponseControl prrc = (PagedResultsResponseControl) controls[i];
+ for (final Control control : controls) {
+ if (control instanceof PagedResultsResponseControl) {
+ final PagedResultsResponseControl prrc = (PagedResultsResponseControl) control;
// total = prrc.getResultSize();
cookie = prrc.getCookie();
}
}
// page suivante
- adContext.setRequestControls(new Control[] { new PagedResultsControl(resultPageSize, cookie, Control.CRITICAL) });
+ adContext.setRequestControls(new Control[] { new PagedResultsControl(this.resultPageSize, cookie, Control.CRITICAL) });
return (cookie != null);
}
- protected SyncType synchronizeUser(Connection connection, ActiveDirectoryUser adUser) throws SQLException {
- Long userId = getUserIdFromGuid(connection, adUser.getGuid());
+ protected SyncType synchronizeUser(final Connection connection, final ActiveDirectoryUser adUser) throws SQLException {
+ final Long userId = this.getUserIdFromGuid(connection, adUser.getGuid());
if (userId == null) {
- return insertXemeliosUser(connection, adUser) ? SyncType.INSERT : SyncType.NONE;
+ return this.insertXemeliosUser(connection, adUser) ? SyncType.INSERT : SyncType.NONE;
} else {
- return updateXemeliosUser(connection, adUser) ? SyncType.UPDATE : SyncType.NONE;
+ return this.updateXemeliosUser(connection, adUser) ? SyncType.UPDATE : SyncType.NONE;
}
}
- protected void unsynchronizeUser(Connection connection, Long userId) throws SQLException {
- String cleanProfiles = queryProvider.getQuery("unsynchronizeUser.cleanProfiles");
- String cleanDocuments = queryProvider.getQuery("unsynchronizeUser.cleanDocuments");
- String cleanCollectivites = queryProvider.getQuery("unsynchronizeUser.cleanCollectivites");
- String deleteUser = queryProvider.getQuery("unsynchronizeUser.deleteUser");
- SimplePStmtBinderBuilder binder = new SimplePStmtBinderBuilder();
+ protected void unsynchronizeUser(final Connection connection, final Long userId) throws SQLException {
+ final String cleanProfiles = this.queryProvider.getQuery("unsynchronizeUser.cleanProfiles");
+ final String cleanDocuments = this.queryProvider.getQuery("unsynchronizeUser.cleanDocuments");
+ final String cleanCollectivites = this.queryProvider.getQuery("unsynchronizeUser.cleanCollectivites");
+ final String deleteUser = this.queryProvider.getQuery("unsynchronizeUser.deleteUser");
+ final SimplePStmtBinderBuilder binder = new SimplePStmtBinderBuilder();
binder.add(userId);
JdbcUtils.executeUpdate(connection, deleteUser, binder.toPStmtBinder());
}
- protected Long getUserIdFromLogin(Connection connection, String login) throws SQLException {
- String getUserIdQuery = queryProvider.getQuery("getUserIdFromLogin");
- SimplePStmtBinderBuilder binder = new SimplePStmtBinderBuilder();
+ protected Long getUserIdFromLogin(final Connection connection, final String login) throws SQLException {
+ final String getUserIdQuery = this.queryProvider.getQuery("getUserIdFromLogin");
+ final SimplePStmtBinderBuilder binder = new SimplePStmtBinderBuilder();
binder.add(login);
return (Long) JdbcUtils.queryObject(connection, getUserIdQuery, new RowMapper.ColToLongRowMapper(), binder.toPStmtBinder());
}
- protected Long getUserIdFromGuid(Connection connection, String guid) throws SQLException {
- String getUserIdQuery = queryProvider.getQuery("getUserIdFromGuid");
- SimplePStmtBinderBuilder binder = new SimplePStmtBinderBuilder();
+ protected Long getUserIdFromGuid(final Connection connection, final String guid) throws SQLException {
+ final String getUserIdQuery = this.queryProvider.getQuery("getUserIdFromGuid");
+ final SimplePStmtBinderBuilder binder = new SimplePStmtBinderBuilder();
binder.add(guid);
return (Long) JdbcUtils.queryObject(connection, getUserIdQuery, new RowMapper.ColToLongRowMapper(), binder.toPStmtBinder());
}
- protected boolean insertXemeliosUser(Connection connection, ActiveDirectoryUser adUser) throws SQLException {
- String query = queryProvider.getQuery("insertXemeliosUser");
- SimplePStmtBinderBuilder binder = new SimplePStmtBinderBuilder();
+ protected boolean insertXemeliosUser(final Connection connection, final ActiveDirectoryUser adUser) throws SQLException {
+ final String query = this.queryProvider.getQuery("insertXemeliosUser");
+ final SimplePStmtBinderBuilder binder = new SimplePStmtBinderBuilder();
binder.add(adUser.getGuid());
binder.add(adUser.getLogin());
return JdbcUtils.executeUpdate(connection, query, binder.toPStmtBinder()).getCountUpdated() == 1;
}
- protected boolean updateXemeliosUser(Connection connection, ActiveDirectoryUser adUser) throws SQLException {
- String query = queryProvider.getQuery("updateXemeliosUser");
+ protected boolean updateXemeliosUser(final Connection connection, final ActiveDirectoryUser adUser) throws SQLException {
+ final String query = this.queryProvider.getQuery("updateXemeliosUser");
- SimplePStmtBinderBuilder binder = new SimplePStmtBinderBuilder();
+ final SimplePStmtBinderBuilder binder = new SimplePStmtBinderBuilder();
binder.add(adUser.getLogin());
binder.add(adUser.getFirstName());
return JdbcUtils.executeUpdate(connection, query, binder.toPStmtBinder()).getCountUpdated() > 0;
}
- protected void updateUserProfiles(Connection connection, ActiveDirectoryUser adUser) throws SQLException {
- String mainAdminAllPower = queryProvider.getQuery("updateUserProfiles.allPower");
- String cleanQuery = queryProvider.getQuery("updateUserProfiles.clean");
- String fillQuery = queryProvider.getQuery("updateUserProfiles.insertProfiles");
- Long userId = getUserIdFromGuid(connection, adUser.getGuid());
+ protected void updateUserProfiles(final Connection connection, final ActiveDirectoryUser adUser) throws SQLException {
+ final String mainAdminAllPower = this.queryProvider.getQuery("updateUserProfiles.allPower");
+ final String cleanQuery = this.queryProvider.getQuery("updateUserProfiles.clean");
+ final String fillQuery = this.queryProvider.getQuery("updateUserProfiles.insertProfiles");
+ final Long userId = this.getUserIdFromGuid(connection, adUser.getGuid());
SimplePStmtBinderBuilder binder = new SimplePStmtBinderBuilder();
binder.add(userId);
JdbcUtils.executeUpdate(connection, cleanQuery, binder.toPStmtBinder());
- for (String adGroupDN : adUser.getMemberOf()) {
+ for (final String adGroupDN : adUser.getMemberOf()) {
binder = new SimplePStmtBinderBuilder();
binder.add(userId);
- if (adGroupDN.equals(mainAdminDn)) {
+ if (adGroupDN.equals(this.mainAdminDn)) {
JdbcUtils.executeUpdate(connection, mainAdminAllPower, binder.toPStmtBinder());
binder.add(XEM_MAIN_ADMIN_PROFILE);
JdbcUtils.executeUpdate(connection, fillQuery, binder.toPStmtBinder());
- } else if (adGroupDN.equals(delegAdminDn)) {
+ } else if (adGroupDN.equals(this.delegAdminDn)) {
binder.add(XEM_DELEGATED_ADMIN_PROFILE);
JdbcUtils.executeUpdate(connection, fillQuery, binder.toPStmtBinder());
- } else if (adGroupDN.equals(userDn)) {
+ } else if (adGroupDN.equals(this.userDn)) {
binder.add(XEM_USER_PROFILE);
JdbcUtils.executeUpdate(connection, fillQuery, binder.toPStmtBinder());
} else {
}
}
- protected void buildUserScopes(Connection connection) throws SQLException {
- String cleanQuery = queryProvider.getQuery("buildUserScopes.clean");
- String getUsers = queryProvider.getQuery("buildUserScopes.getUsers");
- String insertUserScope = queryProvider.getQuery("buildUserScopes.insertUserScope");
+ protected void buildUserScopes(final Connection connection) throws SQLException {
+ final String cleanQuery = this.queryProvider.getQuery("buildUserScopes.clean");
+ final String getUsers = this.queryProvider.getQuery("buildUserScopes.getUsers");
+ final String insertUserScope = this.queryProvider.getQuery("buildUserScopes.insertUserScope");
JdbcUtils.executeUpdate(connection, cleanQuery);
connection.commit();
- List<BuildScopeUser> users = JdbcUtils.queryObjects(connection, getUsers, new RowMapper.ClassRowMapper(BuildScopeUser.class));
- for (BuildScopeUser u : users) {
+ final List<BuildScopeUser> users = JdbcUtils.queryObjects(connection, getUsers, new RowMapper.ClassRowMapper(BuildScopeUser.class));
+ for (final BuildScopeUser u : users) {
logger.debug("Build user scope : " + u.getUtiId() + " (dep:" + u.getDepCode() + ")");
JdbcUtils.executeUpdate(connection, insertUserScope, new PStmtBinder.SimplePStmtBinder(new Object[] { u.getUtiId(), u.getDepCode() }));
connection.commit();
}
}
- protected String getActiveDirectoryCurrentTime(DirContext adContext) throws NamingException, ParseException {
+ protected String getActiveDirectoryCurrentTime(final DirContext adContext) throws NamingException, ParseException {
String result = null;
- SearchControls searchCtrl = new SearchControls();
+ final SearchControls searchCtrl = new SearchControls();
searchCtrl.setSearchScope(SearchControls.OBJECT_SCOPE);
- NamingEnumeration<SearchResult> adRootDSEResult = adContext.search("", "(&(objectClass=*))", searchCtrl);
+ final NamingEnumeration<SearchResult> adRootDSEResult = adContext.search("", "(&(objectClass=*))", searchCtrl);
try {
while (adRootDSEResult.hasMoreElements()) {
- SearchResult sr = (SearchResult) adRootDSEResult.next();
- Attributes attributes = sr.getAttributes();
+ final SearchResult sr = adRootDSEResult.next();
+ final Attributes attributes = sr.getAttributes();
result = attributes.get("currentTime").get().toString();
}
} finally {
return result;
}
- protected void updateLastSyncParameter(String syncDate) throws DataConfigurationException {
- DataImpl dataLayer = DataLayerManager.getImplementation();
+ protected void updateLastSyncParameter(final String syncDate) throws DataConfigurationException {
+ final DataImpl dataLayer = DataLayerManager.getImplementation();
dataLayer.setParameterValue(PARAMETER_AD_LAST_SYNC, syncDate);
}
- protected String builFilter(String originalFilter, String syncDate) {
+ protected String builFilter(final String originalFilter, final String syncDate) {
if (syncDate == null) {
return originalFilter;
}
}
}
- private String buildFilter(String filterTemplate, String mainAdminDn, String delegatedAdminDn, String userDn) {
+ private String buildFilter(final String filterTemplate, final String mainAdminDn, final String delegatedAdminDn, final String userDn) {
String result = filterTemplate.replace(LDAP_MAIN_ADMIN_DN_TOKEN, mainAdminDn);
result = result.replace(LDAP_DELEGATED_ADMIN_DN_TOKEN, delegatedAdminDn);
result = result.replace(LDAP_USER_DN_TOKEN, userDn);
public static class BuildScopeUser {
- private Long utiId;
- private String depCode;
+ private final Long utiId;
+ private final String depCode;
- public BuildScopeUser(ResultSet rs) throws SQLException {
- utiId = rs.getLong(1);
- depCode = rs.getString(2);
+ public BuildScopeUser(final ResultSet rs) throws SQLException {
+ this.utiId = rs.getLong(1);
+ this.depCode = rs.getString(2);
}
public Long getUtiId() {
- return utiId;
+ return this.utiId;
}
public String getDepCode() {
- return depCode;
+ return this.depCode;
}
}
private static final int AD_ACCOUNT_ENABLED = 512;
// private static final int AD_ACCOUNT_DISABLED = 514;
- private String guid;
- private String login;
- private String name;
- private String firstName;
+ private final String guid;
+ private final String login;
+ private final String name;
+ private final String firstName;
private List<String> memberOf;
private boolean enabled;
- private String company;
+ private final String company;
- public ActiveDirectoryUser(Attributes attributes) throws NamingException {
- guid = (String) attributes.get("objectGUID").get();
- login = (String) attributes.get("userPrincipalName").get();
- name = (String) (attributes.get("sn") == null ? null : attributes.get("sn").get());
- firstName = (String) (attributes.get("givenName") == null ? null : attributes.get("givenName").get());
+ public ActiveDirectoryUser(final Attributes attributes) throws NamingException {
+ this.guid = (String) attributes.get("objectGUID").get();
+ this.login = (String) attributes.get("userPrincipalName").get();
+ this.name = (String) (attributes.get("sn") == null ? null : attributes.get("sn").get());
+ this.firstName = (String) (attributes.get("givenName") == null ? null : attributes.get("givenName").get());
if (attributes.get("memberOf") == null) {
- memberOf = Collections.emptyList();
+ this.memberOf = Collections.emptyList();
} else {
- memberOf = new LinkedList<String>();
- NamingEnumeration<?> allGrps = attributes.get("memberOf").getAll();
+ this.memberOf = new LinkedList<String>();
+ final NamingEnumeration<?> allGrps = attributes.get("memberOf").getAll();
try {
while (allGrps.hasMoreElements()) {
- String groupDN = allGrps.next().toString();
- memberOf.add(groupDN);
+ final String groupDN = allGrps.next().toString();
+ this.memberOf.add(groupDN);
}
} finally {
allGrps.close();
}
if (attributes.get("userAccountControl") != null) {
- String uAccCtrl = attributes.get("userAccountControl").get().toString();
- Integer uAccCtrlInt = Integer.parseInt(uAccCtrl);
+ final String uAccCtrl = attributes.get("userAccountControl").get().toString();
+ final Integer uAccCtrlInt = Integer.parseInt(uAccCtrl);
- enabled = ((uAccCtrlInt & AD_ACCOUNT_ENABLED) == AD_ACCOUNT_ENABLED);
+ this.enabled = ((uAccCtrlInt & AD_ACCOUNT_ENABLED) == AD_ACCOUNT_ENABLED);
} else {
// permet de gérer le cas de l'ADAM
- enabled = false;
+ this.enabled = false;
}
- company = (attributes.get("company") == null ? null : (String) attributes.get("company").get());
+ this.company = (attributes.get("company") == null ? null : (String) attributes.get("company").get());
}
public String getGuid() {
- return guid;
+ return this.guid;
}
public String getCompany() {
- return company;
+ return this.company;
}
public String getLogin() {
- return login;
+ return this.login;
}
public String getName() {
- return name;
+ return this.name;
}
public String getFirstName() {
- return firstName;
+ return this.firstName;
}
public List<String> getMemberOf() {
- return memberOf;
+ return this.memberOf;
}
public boolean isEnabled() {
- return enabled;
+ return this.enabled;
}
}
}