Index: lams_central/src/java/org/lamsfoundation/lams/security/LDAPAuthenticator.java =================================================================== diff -u -r0829af2da97bb996efba5faba286ead43c28b5d5 -r60b4757cf25429b45747670da240442c677e9dd1 --- lams_central/src/java/org/lamsfoundation/lams/security/LDAPAuthenticator.java (.../LDAPAuthenticator.java) (revision 0829af2da97bb996efba5faba286ead43c28b5d5) +++ lams_central/src/java/org/lamsfoundation/lams/security/LDAPAuthenticator.java (.../LDAPAuthenticator.java) (revision 60b4757cf25429b45747670da240442c677e9dd1) @@ -44,137 +44,143 @@ import org.springframework.web.context.support.WebApplicationContextUtils; public class LDAPAuthenticator { - - private static Logger log = Logger.getLogger(LDAPAuthenticator.class); - private static UserManagementService service; - private static LdapService ldapService; - private static final String INITIAL_CONTEXT_FACTORY_VALUE = "com.sun.jndi.ldap.LdapCtxFactory"; - private Attributes attrs = null; - - public LDAPAuthenticator() { + + private static Logger log = Logger.getLogger(LDAPAuthenticator.class); + + private static UserManagementService service; + + private static LdapService ldapService; + + private static final String INITIAL_CONTEXT_FACTORY_VALUE = "com.sun.jndi.ldap.LdapCtxFactory"; + + private Attributes attrs = null; + + public LDAPAuthenticator() { + } + + private UserManagementService getService() { + if (service == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(HttpSessionManager + .getInstance().getServletContext()); + service = (UserManagementService) ctx.getBean("userManagementService"); } - - private UserManagementService getService() { - if (service==null) { - WebApplicationContext ctx = WebApplicationContextUtils - .getWebApplicationContext(HttpSessionManager.getInstance().getServletContext()); - service = (UserManagementService) ctx.getBean("userManagementService"); - } - return service; + return service; + } + + private LdapService getLdapService() { + if (ldapService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(HttpSessionManager + .getInstance().getServletContext()); + ldapService = (LdapService) ctx.getBean("ldapService"); } - - private LdapService getLdapService() { - if (ldapService==null) { - WebApplicationContext ctx = WebApplicationContextUtils - .getWebApplicationContext(HttpSessionManager.getInstance().getServletContext()); - ldapService = (LdapService) ctx.getBean("ldapService"); - } - return ldapService; - } + return ldapService; + } - public Attributes getAttrs() { - return attrs; + public Attributes getAttrs() { + return attrs; + } + + public void setAttrs(Attributes attrs) { + this.attrs = attrs; + } + + public boolean authenticate(String username, String inputPassword) { + return authentication(username, inputPassword); + } + + private boolean authentication(String username, Object credential) { + Properties env = new Properties(); + + // Load all authentication method parameters into env + env.setProperty(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY_VALUE); + env.setProperty(Context.SECURITY_AUTHENTICATION, Configuration + .get(ConfigurationKeys.LDAP_SECURITY_AUTHENTICATION)); + + String principalDNPrefix = Configuration.get(ConfigurationKeys.LDAP_PRINCIPAL_DN_PREFIX); + String[] principalDNSuffixes = Configuration.get(ConfigurationKeys.LDAP_PRINCIPAL_DN_SUFFIX).split(";"); + + env.setProperty(Context.PROVIDER_URL, Configuration.get(ConfigurationKeys.LDAP_PROVIDER_URL)); + env.put(Context.SECURITY_CREDENTIALS, credential); + + Object originalTrustStore = System.getProperty("javax.net.ssl.trustStore"); + Object originalTrustPass = System.getProperty("javax.net.ssl.trustStorePassword"); + + String securityProtocol = Configuration.get(ConfigurationKeys.LDAP_SECURITY_PROTOCOL); + if (StringUtils.equals("ssl", securityProtocol)) { + env.setProperty(Context.SECURITY_PROTOCOL, securityProtocol); } - - public void setAttrs(Attributes attrs) { - this.attrs = attrs; - } - - public boolean authenticate(String username, String inputPassword) { - return authentication(username, inputPassword); - } - private boolean authentication(String username, Object credential) { - Properties env = new Properties(); + boolean isValid = false; + InitialLdapContext ctx = null; - // Load all authentication method parameters into env - env.setProperty(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY_VALUE); - env.setProperty(Context.SECURITY_AUTHENTICATION, Configuration.get(ConfigurationKeys.LDAP_SECURITY_AUTHENTICATION)); + for (String principalDNSuffix : principalDNSuffixes) { + if (!principalDNSuffix.startsWith(",")) { + principalDNSuffix = "," + principalDNSuffix; + } + String userDN = principalDNPrefix + username + principalDNSuffix; + env.setProperty(Context.SECURITY_PRINCIPAL, userDN); + try { + ctx = new InitialLdapContext(env, null); + log.debug("===> LDAP context created using DN: " + userDN); + isValid = true; + Attributes attrs = ctx.getAttributes(userDN); + setAttrs(attrs); - String principalDNPrefix = Configuration.get(ConfigurationKeys.LDAP_PRINCIPAL_DN_PREFIX); - String[] principalDNSuffixes = Configuration.get(ConfigurationKeys.LDAP_PRINCIPAL_DN_SUFFIX).split(";"); + if (log.isDebugEnabled()) { + NamingEnumeration enumAttrs = attrs.getAll(); + while (enumAttrs.hasMoreElements()) { + log.debug(enumAttrs.next()); + } + } - env.setProperty(Context.PROVIDER_URL, Configuration.get(ConfigurationKeys.LDAP_PROVIDER_URL)); - env.put(Context.SECURITY_CREDENTIALS, credential); - - Object originalTrustStore = System.getProperty("javax.net.ssl.trustStore"); - Object originalTrustPass = System.getProperty("javax.net.ssl.trustStorePassword"); - - String securityProtocol = Configuration.get(ConfigurationKeys.LDAP_SECURITY_PROTOCOL); - if (StringUtils.equals("ssl", securityProtocol)) { - env.setProperty(Context.SECURITY_PROTOCOL, securityProtocol); + // check user is disabled in ldap + if (getLdapService().getDisabledBoolean(attrs)) { + log.debug("===> User is disabled in LDAP."); + User user = getService().getUserByLogin(username); + if (user != null) { + getService().disableUser(user.getUserId()); + } + return false; } - boolean isValid = false; - InitialLdapContext ctx = null; - - for (String principalDNSuffix : principalDNSuffixes) { - if (!principalDNSuffix.startsWith(",")) { - principalDNSuffix = "," + principalDNSuffix; - } - String userDN = principalDNPrefix + username + principalDNSuffix; - env.setProperty(Context.SECURITY_PRINCIPAL, userDN); - try { - ctx = new InitialLdapContext(env, null); - log.debug("===> LDAP context created using DN: "+userDN); - isValid = true; - Attributes attrs = ctx.getAttributes(userDN); - setAttrs(attrs); - - if (log.isDebugEnabled()) { - NamingEnumeration enumAttrs = attrs.getAll(); - while (enumAttrs.hasMoreElements()) { - log.debug(enumAttrs.next()); - } - } - - // check user is disabled in ldap - if (getLdapService().getDisabledBoolean(attrs)) { - log.debug("===> User is disabled in LDAP."); - User user = getService().getUserByLogin(username); - if (user != null) { - getService().disableUser(user.getUserId()); - } - return false; - } - - if (Configuration.getAsBoolean(ConfigurationKeys.LDAP_UPDATE_ON_LOGIN)) { - User user = getService().getUserByLogin(username); - if (user != null) { - // update user's attributes and org membership - getLdapService().updateLDAPUser(user, attrs); - getLdapService().addLDAPUser(attrs, user.getUserId()); - } - } - - return true; - } catch (AuthenticationNotSupportedException e) { - log.error("===> Authentication mechanism not supported. Check your " - +ConfigurationKeys.LDAP_SECURITY_AUTHENTICATION+" parameter: " - +Configuration.get(ConfigurationKeys.LDAP_SECURITY_AUTHENTICATION)); - } catch (AuthenticationException e) { - log.info("===> Incorrect username ("+userDN+") or password. "+e.getMessage()); - } catch (Exception e) { - log.error("===> LDAP exception: " + e, e); - } finally { + if (Configuration.getAsBoolean(ConfigurationKeys.LDAP_UPDATE_ON_LOGIN)) { + User user = getService().getUserByLogin(username); + if (user != null) { + // update user's attributes and org membership + getLdapService().updateLDAPUser(user, attrs); + getLdapService().addLDAPUser(attrs, user.getUserId()); + } + } - try { - // FIXME: synchronization issue -- dynamically load certificate - // instead of overwritting system properties - //System.setProperty("javax.net.ssl.trustStore",(String)originalTrustStore - // ); - //System.setProperty("javax.net.ssl.trustStorePassword",(String)originalTrustPass - // ); + return true; + } catch (AuthenticationNotSupportedException e) { + log.error("===> Authentication mechanism not supported. Check your " + + ConfigurationKeys.LDAP_SECURITY_AUTHENTICATION + " parameter: " + + Configuration.get(ConfigurationKeys.LDAP_SECURITY_AUTHENTICATION)); + } catch (AuthenticationException e) { + log.info("===> Incorrect username (" + userDN + ") or password. " + e.getMessage()); + } catch (Exception e) { + log.error("===> LDAP exception: " + e, e); + } finally { - if (ctx != null) - ctx.close(); - } catch (Exception e) { - log.error("===> gettting problem when closing context. Exception: "+e); - } - } + try { + // FIXME: synchronization issue -- dynamically load + // certificate + // instead of overwritting system properties + // System.setProperty("javax.net.ssl.trustStore",(String)originalTrustStore + // ); + // System.setProperty("javax.net.ssl.trustStorePassword",(String)originalTrustPass + // ); + + if (ctx != null) + ctx.close(); + } catch (Exception e) { + log.error("===> gettting problem when closing context. Exception: " + e); } - - return isValid; + } } + return isValid; + } + } \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/LdapService.java =================================================================== diff -u -r0829af2da97bb996efba5faba286ead43c28b5d5 -r60b4757cf25429b45747670da240442c677e9dd1 --- lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/LdapService.java (.../LdapService.java) (revision 0829af2da97bb996efba5faba286ead43c28b5d5) +++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/LdapService.java (.../LdapService.java) (revision 60b4757cf25429b45747670da240442c677e9dd1) @@ -61,27 +61,81 @@ /** * @author jliew - * + * */ public class LdapService implements ILdapService { - private Logger log = Logger.getLogger(LdapService.class); - private IUserManagementService service; - private static final int BULK_UPDATE_CREATED = 0; - private static final int BULK_UPDATE_UPDATED = 1; - private static final int BULK_UPDATE_DISABLED = 2; - - public IUserManagementService getService() { - return service; - } + private Logger log = Logger.getLogger(LdapService.class); - public void setService(IUserManagementService service) { - this.service = service; + private IUserManagementService service; + + private static final int BULK_UPDATE_CREATED = 0; + + private static final int BULK_UPDATE_UPDATED = 1; + + private static final int BULK_UPDATE_DISABLED = 2; + + public IUserManagementService getService() { + return service; + } + + public void setService(IUserManagementService service) { + this.service = service; + } + + public void updateLDAPUser(User user, Attributes attrs) { + HashMap map = getLDAPUserAttributes(attrs); + user.setLogin(map.get("login")); + user.setFirstName(map.get("fname")); + user.setLastName(map.get("lname")); + user.setEmail(map.get("email")); + user.setAddressLine1(map.get("address1")); + user.setAddressLine2(map.get("address2")); + user.setAddressLine3(map.get("address3")); + user.setCity(map.get("city")); + user.setState(map.get("state")); + user.setPostcode(map.get("postcode")); + user.setCountry(map.get("country")); + user.setDayPhone(map.get("dayphone")); + user.setEveningPhone(map.get("eveningphone")); + user.setFax(map.get("fax")); + user.setMobilePhone(map.get("mobile")); + user.setLocale(getLocale(map.get("locale"))); + user.setDisabledFlag(getDisabledBoolean(attrs)); + getService().save(user); + } + + // tries to match ldap attribute to a locale, otherwise returns server + // default + private SupportedLocale getLocale(String attribute) { + if (attribute != null && attribute.trim().length() > 0) { + int index = attribute.indexOf("_"); + if (index > 0) { + String language = attribute.substring(0, index); + String country = attribute.substring(index); + return LanguageUtil.getSupportedLocale(language, country); + } else { + return LanguageUtil.getSupportedLocale(attribute); + } } - - public void updateLDAPUser(User user, Attributes attrs) { - HashMap map = getLDAPUserAttributes(attrs); + return LanguageUtil.getDefaultLocale(); + } + + public boolean createLDAPUser(Attributes attrs) { + User user = new User(); + try { + HashMap map = getLDAPUserAttributes(attrs); + if (map.get("login") != null && map.get("login").trim().length() > 0) { + if (log.isDebugEnabled()) { + log.debug("===> using LDAP attributes: " + map.get("login") + "," + map.get("fname") + "," + + map.get("lname") + "," + map.get("email") + "," + map.get("address1") + "," + + map.get("address2") + "," + map.get("address3") + "," + map.get("city") + "," + + map.get("state") + "," + map.get("postcode") + "," + map.get("country") + "," + + map.get("dayphone") + "," + map.get("eveningphone") + "," + map.get("fax") + "," + + map.get("mobile") + "," + map.get("locale")); + } user.setLogin(map.get("login")); + user.setPassword(HashUtil.sha1(RandomPasswordGenerator.nextPassword(10))); user.setFirstName(map.get("fname")); user.setLastName(map.get("lname")); user.setEmail(map.get("email")); @@ -96,489 +150,455 @@ user.setEveningPhone(map.get("eveningphone")); user.setFax(map.get("fax")); user.setMobilePhone(map.get("mobile")); - user.setLocale(getLocale(map.get("locale"))); + user.setAuthenticationMethod((AuthenticationMethod) service.findById(AuthenticationMethod.class, + AuthenticationMethod.LDAP)); + user.setFlashTheme(service.getDefaultFlashTheme()); + user.setHtmlTheme(service.getDefaultHtmlTheme()); user.setDisabledFlag(getDisabledBoolean(attrs)); - getService().save(user); + user.setCreateDate(new Date()); + user.setLocale(getLocale(map.get("locale"))); + service.save(user); + service.auditUserCreated(user, "common"); + return true; + } else { + log.error("===> Login name from LDAP is empty - user not created."); + } + } catch (Exception e) { + log.error("===> Exception occurred while creating LDAP user: ", e); } - - // tries to match ldap attribute to a locale, otherwise returns server default - private SupportedLocale getLocale(String attribute) { - if (attribute!=null && attribute.trim().length()>0) { - int index = attribute.indexOf("_"); - if (index>0) { - String language = attribute.substring(0, index); - String country = attribute.substring(index); - return LanguageUtil.getSupportedLocale(language, country); - } else { - return LanguageUtil.getSupportedLocale(attribute); - } - } - return LanguageUtil.getDefaultLocale(); + return false; + } + + private HashMap getLDAPUserAttributes(Attributes attrs) { + HashMap map = new HashMap(); + try { + map.put("login", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_LOGIN_ATTR)))); + map.put("fname", getSingleAttributeString(attrs.get(Configuration + .get(ConfigurationKeys.LDAP_FIRST_NAME_ATTR)))); + map.put("lname", getSingleAttributeString(attrs.get(Configuration + .get(ConfigurationKeys.LDAP_LAST_NAME_ATTR)))); + map.put("email", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_EMAIL_ATTR)))); + map.put("address1", getSingleAttributeString(attrs + .get(Configuration.get(ConfigurationKeys.LDAP_ADDR1_ATTR)))); + map.put("address2", getSingleAttributeString(attrs + .get(Configuration.get(ConfigurationKeys.LDAP_ADDR2_ATTR)))); + map.put("address3", getSingleAttributeString(attrs + .get(Configuration.get(ConfigurationKeys.LDAP_ADDR3_ATTR)))); + map.put("city", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_CITY_ATTR)))); + map.put("state", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_STATE_ATTR)))); + map.put("postcode", getSingleAttributeString(attrs.get(Configuration + .get(ConfigurationKeys.LDAP_POSTCODE_ATTR)))); + map.put("country", getSingleAttributeString(attrs.get(Configuration + .get(ConfigurationKeys.LDAP_COUNTRY_ATTR)))); + map.put("dayphone", getSingleAttributeString(attrs.get(Configuration + .get(ConfigurationKeys.LDAP_DAY_PHONE_ATTR)))); + map.put("eveningphone", getSingleAttributeString(attrs.get(Configuration + .get(ConfigurationKeys.LDAP_EVENING_PHONE_ATTR)))); + map.put("fax", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_FAX_ATTR)))); + map.put("mobile", + getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_MOBILE_ATTR)))); + map.put("locale", + getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_LOCALE_ATTR)))); + map.put("disabled", getSingleAttributeString(attrs.get(getLdapAttr(Configuration + .get(ConfigurationKeys.LDAP_DISABLED_ATTR))))); + } catch (Exception e) { + log.error("===> Exception occurred while getting LDAP user attributes: ", e); } - - public boolean createLDAPUser(Attributes attrs) { - User user = new User(); - try { - HashMap map = getLDAPUserAttributes(attrs); - if (map.get("login")!=null && map.get("login").trim().length()>0) { - if (log.isDebugEnabled()) { - log.debug("===> using LDAP attributes: " - +map.get("login")+"," - +map.get("fname")+"," - +map.get("lname")+"," - +map.get("email")+"," - +map.get("address1")+"," - +map.get("address2")+"," - +map.get("address3")+"," - +map.get("city")+"," - +map.get("state")+"," - +map.get("postcode")+"," - +map.get("country")+"," - +map.get("dayphone")+"," - +map.get("eveningphone")+"," - +map.get("fax")+"," - +map.get("mobile")+"," - +map.get("locale") - ); - } - user.setLogin(map.get("login")); - user.setPassword(HashUtil.sha1(RandomPasswordGenerator.nextPassword(10))); - user.setFirstName(map.get("fname")); - user.setLastName(map.get("lname")); - user.setEmail(map.get("email")); - user.setAddressLine1(map.get("address1")); - user.setAddressLine2(map.get("address2")); - user.setAddressLine3(map.get("address3")); - user.setCity(map.get("city")); - user.setState(map.get("state")); - user.setPostcode(map.get("postcode")); - user.setCountry(map.get("country")); - user.setDayPhone(map.get("dayphone")); - user.setEveningPhone(map.get("eveningphone")); - user.setFax(map.get("fax")); - user.setMobilePhone(map.get("mobile")); - user.setAuthenticationMethod((AuthenticationMethod)service - .findById(AuthenticationMethod.class, AuthenticationMethod.LDAP)); - user.setFlashTheme(service.getDefaultFlashTheme()); - user.setHtmlTheme(service.getDefaultHtmlTheme()); - user.setDisabledFlag(getDisabledBoolean(attrs)); - user.setCreateDate(new Date()); - user.setLocale(getLocale(map.get("locale"))); - service.save(user); - service.auditUserCreated(user, "common"); - return true; - } else { - log.error("===> Login name from LDAP is empty - user not created."); - } - } catch (Exception e) { - log.error("===> Exception occurred while creating LDAP user: ", e); - } + + // field validation; trim values before they get to database + if (map.get("login") != null && map.get("login").trim().length() > 255) { + map.put("login", map.get("login").substring(0, 255)); + } + if (map.get("fname") != null && map.get("fname").trim().length() > 128) { + map.put("fname", map.get("fname").substring(0, 128)); + } + if (map.get("lname") != null && map.get("lname").trim().length() > 128) { + map.put("lname", map.get("lname").substring(0, 128)); + } + if (map.get("email") != null && map.get("email").trim().length() > 128) { + map.put("email", map.get("email").substring(0, 128)); + } + if (map.get("address1") != null && map.get("address1").trim().length() > 64) { + map.put("address1", map.get("address1").substring(0, 64)); + } + if (map.get("address2") != null && map.get("address2").trim().length() > 64) { + map.put("address2", map.get("address2").substring(0, 64)); + } + if (map.get("address3") != null && map.get("address3").trim().length() > 64) { + map.put("address3", map.get("address3").substring(0, 64)); + } + if (map.get("city") != null && map.get("city").trim().length() > 64) { + map.put("city", map.get("city").substring(0, 64)); + } + if (map.get("state") != null && map.get("state").trim().length() > 64) { + map.put("state", map.get("state").substring(0, 64)); + } + if (map.get("postcode") != null && map.get("postcode").trim().length() > 10) { + map.put("postcode", map.get("postcode").substring(0, 10)); + } + if (map.get("country") != null && map.get("country").trim().length() > 64) { + map.put("country", map.get("country").substring(0, 64)); + } + if (map.get("dayphone") != null && map.get("dayphone").trim().length() > 64) { + map.put("dayphone", map.get("dayphone").substring(0, 64)); + } + if (map.get("eveningphone") != null && map.get("eveningphone").trim().length() > 64) { + map.put("eveningphone", map.get("eveningphone").substring(0, 64)); + } + if (map.get("fax") != null && map.get("fax").trim().length() > 64) { + map.put("fax", map.get("fax").substring(0, 64)); + } + if (map.get("mobile") != null && map.get("mobile").trim().length() > 64) { + map.put("mobile", map.get("mobile").substring(0, 64)); + } + + return map; + } + + public String getLdapAttr(String ldapAttr) { + if (ldapAttr != null) { + return (ldapAttr.startsWith("!") ? ldapAttr.substring(1) : ldapAttr); + } else { + return ldapAttr; + } + } + + private Boolean getAsBoolean(Attribute attr) { + String attrString = getSingleAttributeString(attr); + if (attrString != null) { + if (attrString.equals("1") || attrString.equals("true")) { + return true; + } else if (attrString.equals("0") || attrString.equals("false")) { return false; + } } - - private HashMap getLDAPUserAttributes(Attributes attrs) { - HashMap map = new HashMap(); - try { - map.put("login", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_LOGIN_ATTR)))); - map.put("fname", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_FIRST_NAME_ATTR)))); - map.put("lname", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_LAST_NAME_ATTR)))); - map.put("email", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_EMAIL_ATTR)))); - map.put("address1", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_ADDR1_ATTR)))); - map.put("address2", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_ADDR2_ATTR)))); - map.put("address3", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_ADDR3_ATTR)))); - map.put("city", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_CITY_ATTR)))); - map.put("state", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_STATE_ATTR)))); - map.put("postcode", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_POSTCODE_ATTR)))); - map.put("country", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_COUNTRY_ATTR)))); - map.put("dayphone", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_DAY_PHONE_ATTR)))); - map.put("eveningphone", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_EVENING_PHONE_ATTR)))); - map.put("fax", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_FAX_ATTR)))); - map.put("mobile", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_MOBILE_ATTR)))); - map.put("locale", getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_LOCALE_ATTR)))); - map.put("disabled", getSingleAttributeString(attrs.get( - getLdapAttr(Configuration.get(ConfigurationKeys.LDAP_DISABLED_ATTR)))) - ); - } catch (Exception e) { - log.error("===> Exception occurred while getting LDAP user attributes: ", e); - } + return null; + } - // field validation; trim values before they get to database - if (map.get("login") != null && map.get("login").trim().length() > 255) { - map.put("login", map.get("login").substring(0, 255)); + public boolean getDisabledBoolean(Attributes attrs) { + String ldapDisabledAttrStr = Configuration.get(ConfigurationKeys.LDAP_DISABLED_ATTR); + if (ldapDisabledAttrStr.startsWith("!")) { + ldapDisabledAttrStr = ldapDisabledAttrStr.substring(1); + Attribute ldapDisabledAttr = attrs.get(ldapDisabledAttrStr); + Boolean booleanValue = getAsBoolean(ldapDisabledAttr); + if (booleanValue != null) { + return !booleanValue; + } else { + // if there is no value, assume not disabled + return false; + } + } else { + return getAsBoolean(attrs.get(ldapDisabledAttrStr)); + } + + } + + public boolean addLDAPUser(Attributes attrs, Integer userId) { + User user = (User) service.findById(User.class, userId); + // get ldap attributes for lams org and roles + String ldapOrgAttr = getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_ORG_ATTR))); + List ldapRoles = getAttributeStrings(attrs.get(Configuration.get(ConfigurationKeys.LDAP_ROLES_ATTR))); + // get column name of lams_organisation to match ldapOrgAttr to + String orgField = Configuration.get(ConfigurationKeys.LDAP_ORG_FIELD); + + if (ldapOrgAttr != null && ldapRoles != null && orgField != null) { + // get list of possible matching organisations + log.debug("Looking for organisation to add ldap user to..."); + List orgList = (List) service.findByProperty(Organisation.class, orgField, ldapOrgAttr); + if (orgList != null && !orgList.isEmpty()) { + Organisation org = null; + if (orgList.size() == 1) { + org = (Organisation) orgList.get(0); + } else if (orgList.size() > 1) { + // if there are multiple orgs, select the one that is + // active, if there is one + HashMap properties = new HashMap(); + properties.put(orgField, ldapOrgAttr); + properties.put("organisationState.organisationStateId", OrganisationState.ACTIVE); + orgList = (List) service.findByProperties(Organisation.class, properties); + if (orgList.size() == 1) { + org = (Organisation) orgList.get(0); + } else { + log.warn("More than one LAMS organisation found with the " + orgField + ": " + ldapOrgAttr); + return false; + } } - if (map.get("fname") != null && map.get("fname").trim().length() > 128) { - map.put("fname", map.get("fname").substring(0, 128)); + // if the user is a member of any other groups, remove them + if (Configuration.getAsBoolean(ConfigurationKeys.LDAP_ONLY_ONE_ORG)) { + List uos = service.findByProperty(UserOrganisation.class, "user", user); + if (uos != null) { + for (Object obj : uos) { + UserOrganisation uo = (UserOrganisation) obj; + Organisation currentOrg = uo.getOrganisation(); + if (currentOrg.getOrganisationType().getOrganisationTypeId().equals( + OrganisationType.COURSE_TYPE)) { + if (!currentOrg.equals(org)) { + service.deleteUserOrganisation(user, currentOrg); + } + } + } + } } - if (map.get("lname") != null && map.get("lname").trim().length() > 128) { - map.put("lname", map.get("lname").substring(0, 128)); + // now convert the roles to lams roles and add the user to the + // org + List roleIds = getRoleIds(ldapRoles); + if (roleIds != null && !roleIds.isEmpty()) { + service.setRolesForUserOrganisation(user, org.getOrganisationId(), roleIds); + return true; + } else { + log.warn("Couldn't map any roles from attribute: " + + Configuration.get(ConfigurationKeys.LDAP_ROLES_ATTR)); } - if (map.get("email") != null && map.get("email").trim().length() > 128) { - map.put("email", map.get("email").substring(0, 128)); + } else { + log.warn("No LAMS organisations found with the " + orgField + ": " + ldapOrgAttr); + } + } + return false; + } + + // get list of LAMS role ids from list of ldap roles + private List getRoleIds(List ldapRoles) { + if (ldapRoles != null) { + ArrayList roleIds = new ArrayList(); + for (String role : ldapRoles) { + if (isRoleInList(Configuration.get(ConfigurationKeys.LDAP_LEARNER_MAP), role) + && !roleIds.contains(Role.ROLE_LEARNER.toString())) { + roleIds.add(Role.ROLE_LEARNER.toString()); } - if (map.get("address1") != null && map.get("address1").trim().length() > 64) { - map.put("address1", map.get("address1").substring(0, 64)); + if (isRoleInList(Configuration.get(ConfigurationKeys.LDAP_MONITOR_MAP), role) + && !roleIds.contains(Role.ROLE_MONITOR.toString())) { + roleIds.add(Role.ROLE_MONITOR.toString()); } - if (map.get("address2") != null && map.get("address2").trim().length() > 64) { - map.put("address2", map.get("address2").substring(0, 64)); + if (isRoleInList(Configuration.get(ConfigurationKeys.LDAP_AUTHOR_MAP), role) + && !roleIds.contains(Role.ROLE_AUTHOR.toString())) { + roleIds.add(Role.ROLE_AUTHOR.toString()); } - if (map.get("address3") != null && map.get("address3").trim().length() > 64) { - map.put("address3", map.get("address3").substring(0, 64)); + if (isRoleInList(Configuration.get(ConfigurationKeys.LDAP_GROUP_ADMIN_MAP), role) + && !roleIds.contains(Role.ROLE_GROUP_ADMIN.toString())) { + roleIds.add(Role.ROLE_GROUP_ADMIN.toString()); } - if (map.get("city") != null && map.get("city").trim().length() > 64) { - map.put("city", map.get("city").substring(0, 64)); + if (isRoleInList(Configuration.get(ConfigurationKeys.LDAP_GROUP_MANAGER_MAP), role) + && !roleIds.contains(Role.ROLE_GROUP_MANAGER.toString())) { + roleIds.add(Role.ROLE_GROUP_MANAGER.toString()); } - if (map.get("state") != null && map.get("state").trim().length() > 64) { - map.put("state", map.get("state").substring(0, 64)); - } - if (map.get("postcode") != null && map.get("postcode").trim().length() > 10) { - map.put("postcode", map.get("postcode").substring(0, 10)); - } - if (map.get("country") != null && map.get("country").trim().length() > 64) { - map.put("country", map.get("country").substring(0, 64)); - } - if (map.get("dayphone") != null && map.get("dayphone").trim().length() > 64) { - map.put("dayphone", map.get("dayphone").substring(0, 64)); - } - if (map.get("eveningphone") != null && map.get("eveningphone").trim().length() > 64) { - map.put("eveningphone", map.get("eveningphone").substring(0, 64)); - } - if (map.get("fax") != null && map.get("fax").trim().length() > 64) { - map.put("fax", map.get("fax").substring(0, 64)); - } - if (map.get("mobile") != null && map.get("mobile").trim().length() > 64) { - map.put("mobile", map.get("mobile").substring(0, 64)); - } - - return map; + } + return roleIds; } - - public String getLdapAttr(String ldapAttr) { - if (ldapAttr != null) { - return (ldapAttr.startsWith("!") ? ldapAttr.substring(1) : ldapAttr); - } else { - return ldapAttr; + return null; + } + + private boolean isRoleInList(String list, String role) { + if (list != null && role != null) { + String[] array = list.split(";"); + for (String s : array) { + if (role.contains(s)) { + return true; } + } } - - private Boolean getAsBoolean(Attribute attr) { - String attrString = getSingleAttributeString(attr); - if (attrString!=null) { - if (attrString.equals("1") || attrString.equals("true")) { - return true; - } else if (attrString.equals("0") || attrString.equals("false")) { - return false; - } + return false; + } + + // get the multiple values of an ldap attribute + private List getAttributeStrings(Attribute attr) { + try { + ArrayList attrValues = new ArrayList(); + if (attr != null) { + NamingEnumeration attrEnum = attr.getAll(); + while (attrEnum.hasMore()) { + Object attrValue = attrEnum.next(); + if (attrValue != null) { + attrValues.add(attrValue.toString()); + } } - return null; + return attrValues; + } + } catch (NamingException e) { + log.error("===> Naming exception occurred: " + e.getMessage()); } - - public boolean getDisabledBoolean(Attributes attrs) { - String ldapDisabledAttrStr = Configuration.get(ConfigurationKeys.LDAP_DISABLED_ATTR); - if (ldapDisabledAttrStr.startsWith("!")) { - ldapDisabledAttrStr = ldapDisabledAttrStr.substring(1); - Attribute ldapDisabledAttr = attrs.get(ldapDisabledAttrStr); - Boolean booleanValue = getAsBoolean(ldapDisabledAttr); - if (booleanValue != null) { - return !booleanValue; - } else { - // if there is no value, assume not disabled - return false; - } - } else { - return getAsBoolean(attrs.get(ldapDisabledAttrStr)); + return null; + } + + // get the single (string) value of an ldap attribute + private String getSingleAttributeString(Attribute attr) { + try { + if (attr != null) { + Object attrValue = attr.get(); + if (attrValue != null) { + return attrValue.toString(); } - + } + } catch (NamingException e) { + log.error("===> Naming exception occurred: " + e.getMessage()); } - - public boolean addLDAPUser(Attributes attrs, Integer userId) { - User user = (User)service.findById(User.class, userId); - // get ldap attributes for lams org and roles - String ldapOrgAttr = getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_ORG_ATTR))); - List ldapRoles = getAttributeStrings(attrs.get(Configuration.get(ConfigurationKeys.LDAP_ROLES_ATTR))); - // get column name of lams_organisation to match ldapOrgAttr to - String orgField = Configuration.get(ConfigurationKeys.LDAP_ORG_FIELD); - - if (ldapOrgAttr != null && ldapRoles != null && orgField != null) { - // get list of possible matching organisations - log.debug("Looking for organisation to add ldap user to..."); - List orgList = (List)service.findByProperty(Organisation.class, orgField, ldapOrgAttr); - if (orgList!=null && !orgList.isEmpty()) { - Organisation org = null; - if (orgList.size()==1) { - org = (Organisation)orgList.get(0); - } else if (orgList.size() > 1) { - // if there are multiple orgs, select the one that is active, if there is one - HashMap properties = new HashMap(); - properties.put(orgField, ldapOrgAttr); - properties.put("organisationState.organisationStateId", OrganisationState.ACTIVE); - orgList = (List)service.findByProperties(Organisation.class, properties); - if (orgList.size()==1) { - org = (Organisation)orgList.get(0); - } else { - log.warn("More than one LAMS organisation found with the "+orgField+": "+ldapOrgAttr); - return false; - } - } - // if the user is a member of any other groups, remove them - if (Configuration.getAsBoolean(ConfigurationKeys.LDAP_ONLY_ONE_ORG)) { - List uos = service.findByProperty(UserOrganisation.class, "user", user); - if (uos != null) { - for (Object obj : uos) { - UserOrganisation uo = (UserOrganisation)obj; - Organisation currentOrg = uo.getOrganisation(); - if (currentOrg.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.COURSE_TYPE)) { - if (!currentOrg.equals(org)) { - service.deleteUserOrganisation(user, currentOrg); - } - } - } - } - } - // now convert the roles to lams roles and add the user to the org - List roleIds = getRoleIds(ldapRoles); - if (roleIds!=null && !roleIds.isEmpty()) { - service.setRolesForUserOrganisation(user, org.getOrganisationId(), roleIds); - return true; - } else { - log.warn("Couldn't map any roles from attribute: "+Configuration.get(ConfigurationKeys.LDAP_ROLES_ATTR)); - } - } else { - log.warn("No LAMS organisations found with the "+orgField+": "+ldapOrgAttr); - } - } - return false; + return null; + } + + public BulkUpdateResultDTO bulkUpdate() { + // setup ldap context + Properties env = new Properties(); + env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); + env.setProperty(Context.SECURITY_AUTHENTICATION, Configuration + .get(ConfigurationKeys.LDAP_SECURITY_AUTHENTICATION)); + // make java ldap provider return 10 results at a time instead of + // default 1 + env.setProperty(Context.BATCHSIZE, "10"); + env.setProperty(Context.PROVIDER_URL, Configuration.get(ConfigurationKeys.LDAP_PROVIDER_URL)); + String securityProtocol = Configuration.get(ConfigurationKeys.LDAP_SECURITY_PROTOCOL); + if (StringUtils.equals("ssl", securityProtocol)) { + env.setProperty(Context.SECURITY_PROTOCOL, securityProtocol); } - - // get list of LAMS role ids from list of ldap roles - private List getRoleIds(List ldapRoles) { - if (ldapRoles!=null) { - ArrayList roleIds = new ArrayList(); - for (String role : ldapRoles) { - if (isRoleInList(Configuration.get(ConfigurationKeys.LDAP_LEARNER_MAP), role) - && !roleIds.contains(Role.ROLE_LEARNER.toString())) { - roleIds.add(Role.ROLE_LEARNER.toString()); - } - if (isRoleInList(Configuration.get(ConfigurationKeys.LDAP_MONITOR_MAP), role) - && !roleIds.contains(Role.ROLE_MONITOR.toString())) { - roleIds.add(Role.ROLE_MONITOR.toString()); - } - if (isRoleInList(Configuration.get(ConfigurationKeys.LDAP_AUTHOR_MAP), role) - && !roleIds.contains(Role.ROLE_AUTHOR.toString())) { - roleIds.add(Role.ROLE_AUTHOR.toString()); - } - if (isRoleInList(Configuration.get(ConfigurationKeys.LDAP_GROUP_ADMIN_MAP), role) - && !roleIds.contains(Role.ROLE_GROUP_ADMIN.toString())) { - roleIds.add(Role.ROLE_GROUP_ADMIN.toString()); - } - if (isRoleInList(Configuration.get(ConfigurationKeys.LDAP_GROUP_MANAGER_MAP), role) - && !roleIds.contains(Role.ROLE_GROUP_MANAGER.toString())) { - roleIds.add(Role.ROLE_GROUP_MANAGER.toString()); - } - } - return roleIds; - } - return null; + + // get base DN/s to search on + String[] baseDNs = Configuration.get(ConfigurationKeys.LDAP_PRINCIPAL_DN_SUFFIX).split(";"); + + // get search filter + String filter = Configuration.get(ConfigurationKeys.LDAP_PRINCIPAL_DN_PREFIX); + filter = "(" + filter + (filter.endsWith("=") ? "" : "=") + "*)"; + + // get page size + int pageSize = 100; + try { + pageSize = new Integer(Configuration.get(ConfigurationKeys.LDAP_SEARCH_RESULTS_PAGE_SIZE)).intValue(); + } catch (Exception e) { + log.error("Couldn't read " + ConfigurationKeys.LDAP_SEARCH_RESULTS_PAGE_SIZE + + ", using default page size of 100."); } - - private boolean isRoleInList(String list, String role) { - if (list != null && role != null) { - String[] array = list.split(";"); - for (String s : array) { - if (role.contains(s)) { - return true; - } - } - } - return false; - } - - // get the multiple values of an ldap attribute - private List getAttributeStrings(Attribute attr) { + + int totalResults = 0; + int createdUsers = 0; + int updatedUsers = 0; + int disabledUsers = 0; + List messages = new ArrayList(); + + for (String baseDN : baseDNs) { + int contextResults = 0; + if (baseDN.startsWith(",")) { + baseDN = baseDN.substring(1); + } + try { + // open LDAP connection + LdapContext ctx = null; try { - ArrayList attrValues = new ArrayList(); - if (attr!=null) { - NamingEnumeration attrEnum = attr.getAll(); - while (attrEnum.hasMore()) { - Object attrValue = attrEnum.next(); - if (attrValue!=null) { - attrValues.add(attrValue.toString()); - } - } - return attrValues; - } - } catch (NamingException e) { - log.error("===> Naming exception occurred: "+e.getMessage()); - } - return null; - } - - // get the single (string) value of an ldap attribute - private String getSingleAttributeString(Attribute attr) { - try { - if (attr!=null) { - Object attrValue = attr.get(); - if (attrValue!=null) { - return attrValue.toString(); - } - } - } catch (NamingException e) { - log.error("===> Naming exception occurred: "+e.getMessage()); - } - return null; - } - - public BulkUpdateResultDTO bulkUpdate() { - // setup ldap context - Properties env = new Properties(); - env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); - env.setProperty(Context.SECURITY_AUTHENTICATION, Configuration.get(ConfigurationKeys.LDAP_SECURITY_AUTHENTICATION)); - // make java ldap provider return 10 results at a time instead of default 1 - env.setProperty(Context.BATCHSIZE, "10"); - env.setProperty(Context.PROVIDER_URL, Configuration.get(ConfigurationKeys.LDAP_PROVIDER_URL)); - String securityProtocol = Configuration.get(ConfigurationKeys.LDAP_SECURITY_PROTOCOL); - if (StringUtils.equals("ssl", securityProtocol)) { - env.setProperty(Context.SECURITY_PROTOCOL, securityProtocol); - } - - // get base DN/s to search on - String[] baseDNs = Configuration.get(ConfigurationKeys.LDAP_PRINCIPAL_DN_SUFFIX).split(";"); - - // get search filter - String filter = Configuration.get(ConfigurationKeys.LDAP_PRINCIPAL_DN_PREFIX); - filter = "(" + filter + (filter.endsWith("=") ? "" : "=") + "*)"; - - // get page size - int pageSize = 100; - try { - pageSize = new Integer(Configuration.get(ConfigurationKeys.LDAP_SEARCH_RESULTS_PAGE_SIZE)).intValue(); + ctx = new InitialLdapContext(env, null); + // ask ldap server to return results in pages of PAGE_SIZE, + // if supported + ctx.setRequestControls(new Control[] { new PagedResultsControl(pageSize, Control.NONCRITICAL) }); } catch (Exception e) { - log.error("Couldn't read " + ConfigurationKeys.LDAP_SEARCH_RESULTS_PAGE_SIZE + ", using default page size of 100."); + messages.add("Error creating control."); + log.error(e, e); } - - int totalResults = 0; - int createdUsers = 0; - int updatedUsers = 0; - int disabledUsers = 0; - List messages = new ArrayList(); - - for (String baseDN : baseDNs) { - int contextResults = 0; - if (baseDN.startsWith(",")) { - baseDN = baseDN.substring(1); - } - try { - // open LDAP connection - LdapContext ctx = null; - try { - ctx = new InitialLdapContext(env, null); - // ask ldap server to return results in pages of PAGE_SIZE, if supported - ctx.setRequestControls(new Control[] { - new PagedResultsControl(pageSize, Control.NONCRITICAL) }); - } catch (Exception e) { - messages.add("Error creating control."); - log.error(e, e); - } - - // perform ldap search, in batches - byte[] cookie = null; - do { - // set search to subtree of base dn - SearchControls ctrl = new SearchControls(); - ctrl.setSearchScope(SearchControls.SUBTREE_SCOPE); - - // do the search for all ldap users - NamingEnumeration results = ctx.search(baseDN, filter, ctrl); - while (results.hasMore()) { - SearchResult result = results.next(); - Attributes attrs = result.getAttributes(); - - // add or update this user to LAMS - boolean disabled = getDisabledBoolean(attrs); - String login = getSingleAttributeString(attrs.get(Configuration.get(ConfigurationKeys.LDAP_LOGIN_ATTR))); - if (login != null && login.trim().length() > 0) { - int code = bulkUpdateLDAPUser(login, attrs, disabled); - switch (code) { - case BULK_UPDATE_CREATED: createdUsers++; break; - case BULK_UPDATE_UPDATED: updatedUsers++; break; - case BULK_UPDATE_DISABLED: disabledUsers++; break; - } - } else { - log.error("Couldn't find login attribute for user using attribute name: " - + Configuration.get(ConfigurationKeys.LDAP_LOGIN_ATTR) + ". Dumping attributes..."); - NamingEnumeration enumAttrs = attrs.getAll(); - while (enumAttrs.hasMoreElements()) { - log.error(enumAttrs.next()); - } - } - - contextResults++; - } - - cookie = getPagedResponseCookie(ctx.getResponseControls()); - - // set response cookie to continue paged result - ctx.setRequestControls(new Control[] { - new PagedResultsControl(pageSize, cookie, Control.NONCRITICAL) } - ); - } while (cookie != null); - log.info("Ldap context " + baseDN + " returned " + contextResults + " users."); - ctx.close(); - } catch (Exception e) { - messages.add("Error while processing " + baseDN + ": " + e.getMessage()); - log.error(e, e); - } - totalResults += contextResults; - } - - BulkUpdateResultDTO dto = new BulkUpdateResultDTO(totalResults, createdUsers, updatedUsers, disabledUsers, messages); - - log.info("Ldap returned " + totalResults + " users."); - log.info(createdUsers + " were created, " + updatedUsers + " were updated/existed, and " + disabledUsers + " were disabled."); - - return dto; - } - - // create, update, or disable this user - private int bulkUpdateLDAPUser(String login, Attributes attrs, boolean disabled) { - int returnCode = -1; - User user = getService().getUserByLogin(login); - if (!disabled) { - if (user == null) { - log.info("Creating new user for LDAP username: " + login); - if (createLDAPUser(attrs)) { - user = getService().getUserByLogin(login); - returnCode = BULK_UPDATE_CREATED; - } else { - log.error("Couldn't create new user for LDAP username: "+login); - } + + // perform ldap search, in batches + byte[] cookie = null; + do { + // set search to subtree of base dn + SearchControls ctrl = new SearchControls(); + ctrl.setSearchScope(SearchControls.SUBTREE_SCOPE); + + // do the search for all ldap users + NamingEnumeration results = ctx.search(baseDN, filter, ctrl); + while (results.hasMore()) { + SearchResult result = results.next(); + Attributes attrs = result.getAttributes(); + + // add or update this user to LAMS + boolean disabled = getDisabledBoolean(attrs); + String login = getSingleAttributeString(attrs.get(Configuration + .get(ConfigurationKeys.LDAP_LOGIN_ATTR))); + if (login != null && login.trim().length() > 0) { + int code = bulkUpdateLDAPUser(login, attrs, disabled); + switch (code) { + case BULK_UPDATE_CREATED: + createdUsers++; + break; + case BULK_UPDATE_UPDATED: + updatedUsers++; + break; + case BULK_UPDATE_DISABLED: + disabledUsers++; + break; + } } else { - updateLDAPUser(user, attrs); - returnCode = BULK_UPDATE_UPDATED; + log + .error("Couldn't find login attribute for user using attribute name: " + + Configuration.get(ConfigurationKeys.LDAP_LOGIN_ATTR) + + ". Dumping attributes..."); + NamingEnumeration enumAttrs = attrs.getAll(); + while (enumAttrs.hasMoreElements()) { + log.error(enumAttrs.next()); + } } - if (!addLDAPUser(attrs, user.getUserId())) { - log.error("Couldn't add LDAP user: "+login+" to organisation."); - } + + contextResults++; + } + + cookie = getPagedResponseCookie(ctx.getResponseControls()); + + // set response cookie to continue paged result + ctx.setRequestControls(new Control[] { new PagedResultsControl(pageSize, cookie, + Control.NONCRITICAL) }); + } while (cookie != null); + log.info("Ldap context " + baseDN + " returned " + contextResults + " users."); + ctx.close(); + } catch (Exception e) { + messages.add("Error while processing " + baseDN + ": " + e.getMessage()); + log.error(e, e); + } + totalResults += contextResults; + } + + BulkUpdateResultDTO dto = new BulkUpdateResultDTO(totalResults, createdUsers, updatedUsers, disabledUsers, + messages); + + log.info("Ldap returned " + totalResults + " users."); + log.info(createdUsers + " were created, " + updatedUsers + " were updated/existed, and " + disabledUsers + + " were disabled."); + + return dto; + } + + // create, update, or disable this user + private int bulkUpdateLDAPUser(String login, Attributes attrs, boolean disabled) { + int returnCode = -1; + User user = getService().getUserByLogin(login); + if (!disabled) { + if (user == null) { + log.info("Creating new user for LDAP username: " + login); + if (createLDAPUser(attrs)) { + user = getService().getUserByLogin(login); + returnCode = BULK_UPDATE_CREATED; } else { - // remove user from groups and set disabled flag - if (user != null) { - getService().disableUser(user.getUserId()); - returnCode = BULK_UPDATE_DISABLED; - } + log.error("Couldn't create new user for LDAP username: " + login); } - return returnCode; + } else { + updateLDAPUser(user, attrs); + returnCode = BULK_UPDATE_UPDATED; + } + if (!addLDAPUser(attrs, user.getUserId())) { + log.error("Couldn't add LDAP user: " + login + " to organisation."); + } + } else { + // remove user from groups and set disabled flag + if (user != null) { + getService().disableUser(user.getUserId()); + returnCode = BULK_UPDATE_DISABLED; + } } - - // get paged result response cookie - private byte[] getPagedResponseCookie(Control[] controls) { - if (controls != null) { - for (Control control : controls) { - if (control instanceof PagedResultsResponseControl) { - PagedResultsResponseControl prrc = (PagedResultsResponseControl)control; - return prrc.getCookie(); - } - } + return returnCode; + } + + // get paged result response cookie + private byte[] getPagedResponseCookie(Control[] controls) { + if (controls != null) { + for (Control control : controls) { + if (control instanceof PagedResultsResponseControl) { + PagedResultsResponseControl prrc = (PagedResultsResponseControl) control; + return prrc.getCookie(); } - return null; + } } - + return null; + } + } Index: lams_common/src/java/org/lamsfoundation/lams/util/Configuration.java =================================================================== diff -u -r0829af2da97bb996efba5faba286ead43c28b5d5 -r60b4757cf25429b45747670da240442c677e9dd1 --- lams_common/src/java/org/lamsfoundation/lams/util/Configuration.java (.../Configuration.java) (revision 0829af2da97bb996efba5faba286ead43c28b5d5) +++ lams_common/src/java/org/lamsfoundation/lams/util/Configuration.java (.../Configuration.java) (revision 60b4757cf25429b45747670da240442c677e9dd1) @@ -43,133 +43,128 @@ */ public class Configuration implements InitializingBean { - - protected Logger log = Logger.getLogger(Configuration.class); - - public static String CONFIGURATION_HELP_PAGE = "LAMS+Configuration"; - private static Map items = null; + protected Logger log = Logger.getLogger(Configuration.class); - protected ConfigurationDAO configurationDAO; - - /** - * @param configurationDAO The configurationDAO to set. - */ - public void setConfigurationDAO(ConfigurationDAO configurationDAO) { - this.configurationDAO = configurationDAO; + public static String CONFIGURATION_HELP_PAGE = "LAMS+Configuration"; + + private static Map items = null; + + protected ConfigurationDAO configurationDAO; + + /** + * @param configurationDAO + * The configurationDAO to set. + */ + public void setConfigurationDAO(ConfigurationDAO configurationDAO) { + this.configurationDAO = configurationDAO; + } + + public void afterPropertiesSet() { + if (items != null) { + return; } - - - public void afterPropertiesSet() { - if(items != null) { - return; - } - - Map itemsmap = Collections.synchronizedMap(new LinkedHashMap()); - - try { - List mapitems = getAllItems(); - if(mapitems.size() > 0) { - Iterator it = mapitems.iterator(); - while(it.hasNext()) { - ConfigurationItem item = (ConfigurationItem) it.next(); - - // init ssl truststore path and password - if (StringUtils.equals(item.getKey(), ConfigurationKeys.TRUSTSTORE_PATH)) { - setSystemProperty(item.getKey(), item.getValue()); - } else if (StringUtils.equals(item.getKey(), ConfigurationKeys.TRUSTSTORE_PASSWORD)) { - setSystemProperty(item.getKey(), item.getValue()); - } - - itemsmap.put(item.getKey(), item); - } - } - - items = itemsmap; - - } catch (Exception e) { - log.error("Exception has occurred: ",e); + Map itemsmap = Collections.synchronizedMap(new LinkedHashMap()); + + try { + List mapitems = getAllItems(); + + if (mapitems.size() > 0) { + Iterator it = mapitems.iterator(); + while (it.hasNext()) { + ConfigurationItem item = (ConfigurationItem) it.next(); + + // init ssl truststore path and password + if (StringUtils.equals(item.getKey(), ConfigurationKeys.TRUSTSTORE_PATH)) { + setSystemProperty(item.getKey(), item.getValue()); + } else if (StringUtils.equals(item.getKey(), ConfigurationKeys.TRUSTSTORE_PASSWORD)) { + setSystemProperty(item.getKey(), item.getValue()); + } + + itemsmap.put(item.getKey(), item); } - } - - public List getAllItems() { - return configurationDAO.getAllItems(); - } - - public static Map getAll() { - return items; - } - - public ConfigurationItem getConfigItemByKey(String key) { - if ((items != null)&&(items.get(key)!=null)) - if (items.get(key)!=null) - return (ConfigurationItem)items.get(key); - return null; - } - - public static String getItemValue(Object obj) { - ConfigurationItem item = (ConfigurationItem) obj; - if(item.getValue() != null) - return item.getValue(); - return null; - } - - public static void setItemValue(Object obj, String value) { - ConfigurationItem item = (ConfigurationItem) obj; - item.setValue(value); - } - - public static String get(String key) - { - if ((items != null)&&(items.get(key)!=null)) - if(getItemValue(items.get(key)) != null) - return getItemValue(items.get(key)); - return null; - } + } - public static int getAsInt(String key) - { - if ((items != null)&&(items.get(key)!=null)) - //could throw NumberFormatException which is a RuntimeException - if(getItemValue(items.get(key)) != null) - return new Integer(getItemValue(items.get(key))).intValue(); - return -1; + items = itemsmap; + + } catch (Exception e) { + log.error("Exception has occurred: ", e); } + } - public static boolean getAsBoolean(String key) - { - if((items != null)&&(items.get(key)!=null)) - if(getItemValue(items.get(key)) != null) - return new Boolean(getItemValue(items.get(key))).booleanValue(); - return false; + public List getAllItems() { + return configurationDAO.getAllItems(); + } + + public static Map getAll() { + return items; + } + + public ConfigurationItem getConfigItemByKey(String key) { + if ((items != null) && (items.get(key) != null)) + if (items.get(key) != null) + return (ConfigurationItem) items.get(key); + return null; + } + + public static String getItemValue(Object obj) { + ConfigurationItem item = (ConfigurationItem) obj; + if (item.getValue() != null) + return item.getValue(); + return null; + } + + public static void setItemValue(Object obj, String value) { + ConfigurationItem item = (ConfigurationItem) obj; + item.setValue(value); + } + + public static String get(String key) { + if ((items != null) && (items.get(key) != null)) + if (getItemValue(items.get(key)) != null) + return getItemValue(items.get(key)); + return null; + } + + public static int getAsInt(String key) { + if ((items != null) && (items.get(key) != null)) + // could throw NumberFormatException which is a RuntimeException + if (getItemValue(items.get(key)) != null) + return new Integer(getItemValue(items.get(key))).intValue(); + return -1; + } + + public static boolean getAsBoolean(String key) { + if ((items != null) && (items.get(key) != null)) + if (getItemValue(items.get(key)) != null) + return new Boolean(getItemValue(items.get(key))).booleanValue(); + return false; + } + + public static void updateItem(String key, String value) { + if (items.containsKey(key)) + setItemValue(items.get(key), value); + } + + public void persistUpdate() { + // update ssl truststore path and password + setSystemProperty(ConfigurationKeys.TRUSTSTORE_PATH, get(ConfigurationKeys.TRUSTSTORE_PATH)); + setSystemProperty(ConfigurationKeys.TRUSTSTORE_PASSWORD, get(ConfigurationKeys.TRUSTSTORE_PASSWORD)); + configurationDAO.insertOrUpdateAll(items.values()); + } + + public String toString() { + return "Configuration items:" + (items != null ? items.toString() : "none"); + } + + // update jvm system property + private void setSystemProperty(String key, String value) { + if (StringUtils.isBlank(key)) { + // use default + System.clearProperty(key); + } else { + System.setProperty(key, value); } - - public static void updateItem(String key, String value) { - if(items.containsKey(key)) - setItemValue(items.get(key), value); - } - - public void persistUpdate() { - // update ssl truststore path and password - setSystemProperty(ConfigurationKeys.TRUSTSTORE_PATH, get(ConfigurationKeys.TRUSTSTORE_PATH)); - setSystemProperty(ConfigurationKeys.TRUSTSTORE_PASSWORD, get(ConfigurationKeys.TRUSTSTORE_PASSWORD)); - configurationDAO.insertOrUpdateAll(items.values()); - } - - public String toString() - { - return "Configuration items:" - + ( items!=null ? items.toString() : "none" ) ; - } - - // update jvm system property - private void setSystemProperty(String key, String value) { - if (StringUtils.isBlank(key)) { - // use default - System.clearProperty(key); - } else { - System.setProperty(key, value); - } - } - + } + } Index: lams_common/src/java/org/lamsfoundation/lams/util/ConfigurationKeys.java =================================================================== diff -u -r0829af2da97bb996efba5faba286ead43c28b5d5 -r60b4757cf25429b45747670da240442c677e9dd1 --- lams_common/src/java/org/lamsfoundation/lams/util/ConfigurationKeys.java (.../ConfigurationKeys.java) (revision 0829af2da97bb996efba5faba286ead43c28b5d5) +++ lams_common/src/java/org/lamsfoundation/lams/util/ConfigurationKeys.java (.../ConfigurationKeys.java) (revision 60b4757cf25429b45747670da240442c677e9dd1) @@ -31,200 +31,214 @@ */ public class ConfigurationKeys { - public static String ROOT = "Lams"; + public static String ROOT = "Lams"; - public static String SERVER_URL = "ServerURL"; - public static String SERVER_URL_CONTEXT_PATH = "ServerURLContextPath"; + public static String SERVER_URL = "ServerURL"; - public static String VERSION = "Version"; + public static String SERVER_URL_CONTEXT_PATH = "ServerURLContextPath"; - public static String LAMS_TEMP_DIR = "TempDir"; + public static String VERSION = "Version"; - /** - * Directory in which lams.ear is deployed. Usually - * {JBOSS}/server/default/deploy/lams.ear - */ - public static String LAMS_EAR_DIR = "EARDir"; + public static String LAMS_TEMP_DIR = "TempDir"; - public static String SMTP_SERVER = "SMTPServer"; + /** + * Directory in which lams.ear is deployed. Usually + * {JBOSS}/server/default/deploy/lams.ear + */ + public static String LAMS_EAR_DIR = "EARDir"; - public static String LAMS_ADMIN_EMAIL = "LamsSupportEmail"; + public static String SMTP_SERVER = "SMTPServer"; - /** - * Flash crash dump files (see FlashCrashDump servlet) are written to the - * Dump directory - */ - public static String LAMS_DUMP_DIR = "DumpDir"; + public static String LAMS_ADMIN_EMAIL = "LamsSupportEmail"; - public static String CONTENT_REPOSITORY_PATH = "ContentRepositoryPath"; + /** + * Flash crash dump files (see FlashCrashDump servlet) are written to the + * Dump directory + */ + public static String LAMS_DUMP_DIR = "DumpDir"; - public static String UPLOAD_FILE_MAX_SIZE = "UploadFileMaxSize"; + public static String CONTENT_REPOSITORY_PATH = "ContentRepositoryPath"; - public static String UPLOAD_FILE_LARGE_MAX_SIZE = "UploadLargeFileMaxSize"; + public static String UPLOAD_FILE_MAX_SIZE = "UploadFileMaxSize"; - public static String UPLOAD_FILE_MAX_MEMORY_SIZE = "UploadFileMaxMemorySize"; + public static String UPLOAD_FILE_LARGE_MAX_SIZE = "UploadLargeFileMaxSize"; - public static String CHAT_SERVER_NAME = "ChatServerName"; + public static String UPLOAD_FILE_MAX_MEMORY_SIZE = "UploadFileMaxMemorySize"; - public static String CHAT_PORT_NUMBER = "ChatPortNumber"; + public static String CHAT_SERVER_NAME = "ChatServerName"; - public static String EXE_EXTENSIONS = "ExecutableExtensions"; + public static String CHAT_PORT_NUMBER = "ChatPortNumber"; - public static String LICENSE_TICKET_FILE = "TicketFile"; + public static String EXE_EXTENSIONS = "ExecutableExtensions"; - public static String PREVIEW_CLEANUP_NUM_DAYS = "CleanupPreviewOlderThanDays"; + public static String LICENSE_TICKET_FILE = "TicketFile"; - /** - * Number of milliseconds before a user is considered "inactive". - * "Anonymous" sessions are ended after this period (ie ones that haven't - * ever access one of the clients ) - */ - public static String INACTIVE_TIME = "UserInactiveTimeout"; + public static String PREVIEW_CLEANUP_NUM_DAYS = "CleanupPreviewOlderThanDays"; - /** - * Allow more than one session to exist for one user. Needed for the test - * harness Do not set this parameter to true in production. - */ - public static String ALLOW_MULTIPLE_LOGIN = "AllowMultipleLogin"; + /** + * Number of milliseconds before a user is considered "inactive". + * "Anonymous" sessions are ended after this period (ie ones that haven't + * ever access one of the clients ) + */ + public static String INACTIVE_TIME = "UserInactiveTimeout"; - /** - * Turn on the cache debugging listener. Logs whenever an item is - * added/removed/evicted to/from the cache. Not on in production. Must be - * set to a boolean value - */ - public static String USE_CACHE_DEBUG_LISTENER = "UseCacheDebugListener"; + /** + * Allow more than one session to exist for one user. Needed for the test + * harness Do not set this parameter to true in production. + */ + public static String ALLOW_MULTIPLE_LOGIN = "AllowMultipleLogin"; - /** Value for controlling style colour on Canvas Activities */ - public static String AUTHORING_ACTS_COLOUR = "AuthoringActivitiesColour"; - - /** Values for client updates */ - public static String AUTHORING_CLIENT_VERSION = "AuthoringClientVersion"; + /** + * Turn on the cache debugging listener. Logs whenever an item is + * added/removed/evicted to/from the cache. Not on in production. Must be + * set to a boolean value + */ + public static String USE_CACHE_DEBUG_LISTENER = "UseCacheDebugListener"; - public static String LEARNER_CLIENT_VERSION = "LearnerClientVersion"; + /** Value for controlling style colour on Canvas Activities */ + public static String AUTHORING_ACTS_COLOUR = "AuthoringActivitiesColour"; - public static String MONITOR_CLIENT_VERSION = "MonitorClientVersion"; + /** Values for client updates */ + public static String AUTHORING_CLIENT_VERSION = "AuthoringClientVersion"; - public static String SERVER_VERSION_NUMBER = "ServerVersionNumber"; + public static String LEARNER_CLIENT_VERSION = "LearnerClientVersion"; - /** Default locale for the server. Originally en_AU */ - public static String SERVER_LANGUAGE = "ServerLanguage"; + public static String MONITOR_CLIENT_VERSION = "MonitorClientVersion"; - /** Direction (left to right, right to left) for writing on HTML pages. Originally LTR */ - public static String SERVER_PAGE_DIRECTION = "ServerPageDirection"; + public static String SERVER_VERSION_NUMBER = "ServerVersionNumber"; - /** universal date of dictionary updates */ - public static String DICTIONARY_DATE_CREATED = "DictionaryDateCreated"; + /** Default locale for the server. Originally en_AU */ + public static String SERVER_LANGUAGE = "ServerLanguage"; - public static String HELP_URL = "HelpURL"; - - public static String XMPP_DOMAIN = "XmppDomain"; + /** + * Direction (left to right, right to left) for writing on HTML pages. + * Originally LTR + */ + public static String SERVER_PAGE_DIRECTION = "ServerPageDirection"; - public static String XMPP_CONFERENCE = "XmppConference"; + /** universal date of dictionary updates */ + public static String DICTIONARY_DATE_CREATED = "DictionaryDateCreated"; - public static String XMPP_ADMIN = "XmppAdmin"; + public static String HELP_URL = "HelpURL"; - public static String XMPP_PASSWORD = "XmppPassword"; + public static String XMPP_DOMAIN = "XmppDomain"; - public static String DEFAULT_FLASH_THEME = "DefaultFlashTheme"; - - public static String DEFAULT_HTML_THEME = "DefaultHTMLTheme"; - - public static String ALLOW_DIRECT_LESSON_LAUNCH = "AllowDirectLessonLaunch"; - - public static String LAMS_COMMUNITY_ENABLE = "LAMS_Community_enable"; + public static String XMPP_CONFERENCE = "XmppConference"; - public static String ALLOW_EDIT_ON_FLY = "AllowLiveEdit"; - - public static String LDAP_PROVISIONING_ENABLED = "LDAPProvisioningEnabled"; - - public static String LDAP_PROVIDER_URL = "LDAPProviderURL"; - - public static String LDAP_SECURITY_AUTHENTICATION = "LDAPSecurityAuthentication"; - - public static String LDAP_PRINCIPAL_DN_PREFIX = "LDAPPrincipalDNPrefix"; - - public static String LDAP_PRINCIPAL_DN_SUFFIX = "LDAPPrincipalDNSuffix"; - - public static String LDAP_SECURITY_PROTOCOL = "LDAPSecurityProtocol"; - - public static String TRUSTSTORE_PATH = "TruststorePath"; - - public static String TRUSTSTORE_PASSWORD = "TruststorePassword"; - - public static String LDAP_LOGIN_ATTR = "LDAPLoginAttr"; - - public static String LDAP_FIRST_NAME_ATTR = "LDAPFNameAttr"; - - public static String LDAP_LAST_NAME_ATTR = "LDAPLNameAttr"; - - public static String LDAP_EMAIL_ATTR = "LDAPEmailAttr"; - - public static String LDAP_ADDR1_ATTR = "LDAPAddr1Attr"; - - public static String LDAP_ADDR2_ATTR = "LDAPAddr2Attr"; - - public static String LDAP_ADDR3_ATTR = "LDAPAddr3Attr"; - - public static String LDAP_CITY_ATTR = "LDAPCityAttr"; - - public static String LDAP_STATE_ATTR = "LDAPStateAttr"; - - public static String LDAP_POSTCODE_ATTR = "LDAPPostcodeAttr"; - - public static String LDAP_COUNTRY_ATTR = "LDAPCountryAttr"; - - public static String LDAP_DAY_PHONE_ATTR = "LDAPDayPhoneAttr"; - - public static String LDAP_EVENING_PHONE_ATTR = "LDAPEveningPhoneAttr"; - - public static String LDAP_FAX_ATTR = "LDAPFaxAttr"; - - public static String LDAP_MOBILE_ATTR = "LDAPMobileAttr"; - - public static String LDAP_LOCALE_ATTR = "LDAPLocaleAttr"; - - public static String LDAP_DISABLED_ATTR = "LDAPDisabledAttr"; - - public static String LDAP_ORG_ATTR = "LDAPOrgAttr"; - - public static String LDAP_ROLES_ATTR = "LDAPRolesAttr"; - - public static String LDAP_LEARNER_MAP = "LDAPLearnerMap"; - - public static String LDAP_MONITOR_MAP = "LDAPMonitorMap"; - - public static String LDAP_AUTHOR_MAP = "LDAPAuthorMap"; - - public static String LDAP_GROUP_ADMIN_MAP = "LDAPGroupAdminMap"; - - public static String LDAP_GROUP_MANAGER_MAP = "LDAPGroupManagerMap"; - - public static String LDAP_UPDATE_ON_LOGIN = "LDAPUpdateOnLogin"; - - public static String LDAP_ORG_FIELD = "LDAPOrgField"; - - public static String LDAP_ONLY_ONE_ORG = "LDAPOnlyOneOrg"; - - public static String LDAP_ENCRYPT_PASSWORD_FROM_BROWSER = "LDAPEncryptPasswordFromBrowser"; - - public static String LDAP_SEARCH_RESULTS_PAGE_SIZE = "LDAPSearchResultsPageSize"; - - /** Number of learners to be displayed on the learner progress screen in monitoring. */ - public static String LEARNER_PROGRESS_BATCH_SIZE = "LearnerProgressBatchSize"; - - /** Custom tab for the main page */ - public static String CUSTOM_TAB_LINK = "CustomTabLink"; - public static String CUSTOM_TAB_TITLE = "CustomTabTitle"; - - /** Disable Flash altogether for the learner interface (LDEV-1005) */ - public static String FLASH_ENABLE = "EnableFlash"; - - /** Configurable screen sizes for authoring, monitor, learner and admin (LDEV-1598) */ - public static String AUTHORING_SCREEN_SIZE = "AuthoringScreenSize"; - public static String MONITOR_SCREEN_SIZE = "MonitorScreenSize"; - public static String LEARNER_SCREEN_SIZE = "LearnerScreenSize"; - public static String ADMIN_SCREEN_SIZE = "AdminScreenSize"; - - public static String GMAP_KEY = "GmapKey"; - + public static String XMPP_ADMIN = "XmppAdmin"; + + public static String XMPP_PASSWORD = "XmppPassword"; + + public static String DEFAULT_FLASH_THEME = "DefaultFlashTheme"; + + public static String DEFAULT_HTML_THEME = "DefaultHTMLTheme"; + + public static String ALLOW_DIRECT_LESSON_LAUNCH = "AllowDirectLessonLaunch"; + + public static String LAMS_COMMUNITY_ENABLE = "LAMS_Community_enable"; + + public static String ALLOW_EDIT_ON_FLY = "AllowLiveEdit"; + + public static String LDAP_PROVISIONING_ENABLED = "LDAPProvisioningEnabled"; + + public static String LDAP_PROVIDER_URL = "LDAPProviderURL"; + + public static String LDAP_SECURITY_AUTHENTICATION = "LDAPSecurityAuthentication"; + + public static String LDAP_PRINCIPAL_DN_PREFIX = "LDAPPrincipalDNPrefix"; + + public static String LDAP_PRINCIPAL_DN_SUFFIX = "LDAPPrincipalDNSuffix"; + + public static String LDAP_SECURITY_PROTOCOL = "LDAPSecurityProtocol"; + + public static String TRUSTSTORE_PATH = "TruststorePath"; + + public static String TRUSTSTORE_PASSWORD = "TruststorePassword"; + + public static String LDAP_LOGIN_ATTR = "LDAPLoginAttr"; + + public static String LDAP_FIRST_NAME_ATTR = "LDAPFNameAttr"; + + public static String LDAP_LAST_NAME_ATTR = "LDAPLNameAttr"; + + public static String LDAP_EMAIL_ATTR = "LDAPEmailAttr"; + + public static String LDAP_ADDR1_ATTR = "LDAPAddr1Attr"; + + public static String LDAP_ADDR2_ATTR = "LDAPAddr2Attr"; + + public static String LDAP_ADDR3_ATTR = "LDAPAddr3Attr"; + + public static String LDAP_CITY_ATTR = "LDAPCityAttr"; + + public static String LDAP_STATE_ATTR = "LDAPStateAttr"; + + public static String LDAP_POSTCODE_ATTR = "LDAPPostcodeAttr"; + + public static String LDAP_COUNTRY_ATTR = "LDAPCountryAttr"; + + public static String LDAP_DAY_PHONE_ATTR = "LDAPDayPhoneAttr"; + + public static String LDAP_EVENING_PHONE_ATTR = "LDAPEveningPhoneAttr"; + + public static String LDAP_FAX_ATTR = "LDAPFaxAttr"; + + public static String LDAP_MOBILE_ATTR = "LDAPMobileAttr"; + + public static String LDAP_LOCALE_ATTR = "LDAPLocaleAttr"; + + public static String LDAP_DISABLED_ATTR = "LDAPDisabledAttr"; + + public static String LDAP_ORG_ATTR = "LDAPOrgAttr"; + + public static String LDAP_ROLES_ATTR = "LDAPRolesAttr"; + + public static String LDAP_LEARNER_MAP = "LDAPLearnerMap"; + + public static String LDAP_MONITOR_MAP = "LDAPMonitorMap"; + + public static String LDAP_AUTHOR_MAP = "LDAPAuthorMap"; + + public static String LDAP_GROUP_ADMIN_MAP = "LDAPGroupAdminMap"; + + public static String LDAP_GROUP_MANAGER_MAP = "LDAPGroupManagerMap"; + + public static String LDAP_UPDATE_ON_LOGIN = "LDAPUpdateOnLogin"; + + public static String LDAP_ORG_FIELD = "LDAPOrgField"; + + public static String LDAP_ONLY_ONE_ORG = "LDAPOnlyOneOrg"; + + public static String LDAP_ENCRYPT_PASSWORD_FROM_BROWSER = "LDAPEncryptPasswordFromBrowser"; + + public static String LDAP_SEARCH_RESULTS_PAGE_SIZE = "LDAPSearchResultsPageSize"; + + /** + * Number of learners to be displayed on the learner progress screen in + * monitoring. + */ + public static String LEARNER_PROGRESS_BATCH_SIZE = "LearnerProgressBatchSize"; + + /** Custom tab for the main page */ + public static String CUSTOM_TAB_LINK = "CustomTabLink"; + + public static String CUSTOM_TAB_TITLE = "CustomTabTitle"; + + /** Disable Flash altogether for the learner interface (LDEV-1005) */ + public static String FLASH_ENABLE = "EnableFlash"; + + /** + * Configurable screen sizes for authoring, monitor, learner and admin + * (LDEV-1598) + */ + public static String AUTHORING_SCREEN_SIZE = "AuthoringScreenSize"; + + public static String MONITOR_SCREEN_SIZE = "MonitorScreenSize"; + + public static String LEARNER_SCREEN_SIZE = "LearnerScreenSize"; + + public static String ADMIN_SCREEN_SIZE = "AdminScreenSize"; + + public static String GMAP_KEY = "GmapKey"; + } \ No newline at end of file