Author: solomax
Date: Wed Apr  8 17:11:20 2015
New Revision: 1672122

URL: http://svn.apache.org/r1672122
Log:
[OPENMEETINGS-1196] OAuth is fixed to work as expected, code clean-up

Modified:
    
openmeetings/branches/3.0.x/src/db/java/org/apache/openmeetings/db/dao/user/UserDao.java
    
openmeetings/branches/3.0.x/src/db/java/org/apache/openmeetings/db/entity/server/OAuthServer.java
    
openmeetings/branches/3.0.x/src/db/java/org/apache/openmeetings/db/entity/user/User.java
    
openmeetings/branches/3.0.x/src/install/java/org/apache/openmeetings/installation/ImportInitvalues.java
    
openmeetings/branches/3.0.x/src/main/java/org/apache/openmeetings/data/user/UserManager.java
    
openmeetings/branches/3.0.x/src/main/java/org/apache/openmeetings/ldap/LdapLoginManagement.java
    
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/admin/oauth/OAuthForm.java
    
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/admin/oauth/OAuthPanel.html
    
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/admin/users/UserForm.java
    
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/app/WebSession.java
    
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/common/GeneralUserForm.java
    
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/ForgetPasswordDialog.java
    
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/RegisterDialog.java
    
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/SignInDialog.java
    
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/SignInPage.java
    
openmeetings/trunk/singlewebapp/openmeetings-core/src/main/java/org/apache/openmeetings/core/ldap/LdapLoginManagement.java
    
openmeetings/trunk/singlewebapp/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
    
openmeetings/trunk/singlewebapp/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/server/OAuthServer.java
    
openmeetings/trunk/singlewebapp/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/User.java
    
openmeetings/trunk/singlewebapp/openmeetings-install/src/main/java/org/apache/openmeetings/installation/ImportInitvalues.java
    
openmeetings/trunk/singlewebapp/openmeetings-service/src/main/java/org/apache/openmeetings/service/user/UserManager.java
    
openmeetings/trunk/singlewebapp/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/oauth/OAuthForm.java
    
openmeetings/trunk/singlewebapp/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/oauth/OAuthPanel.html
    
openmeetings/trunk/singlewebapp/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/users/UserForm.java
    
openmeetings/trunk/singlewebapp/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
    
openmeetings/trunk/singlewebapp/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/GeneralUserForm.java
    
openmeetings/trunk/singlewebapp/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/auth/ForgetPasswordDialog.java
    
openmeetings/trunk/singlewebapp/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/auth/RegisterDialog.java
    
openmeetings/trunk/singlewebapp/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/auth/SignInDialog.java
    
openmeetings/trunk/singlewebapp/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/auth/SignInPage.java

Modified: 
openmeetings/branches/3.0.x/src/db/java/org/apache/openmeetings/db/dao/user/UserDao.java
URL: 
http://svn.apache.org/viewvc/openmeetings/branches/3.0.x/src/db/java/org/apache/openmeetings/db/dao/user/UserDao.java?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/branches/3.0.x/src/db/java/org/apache/openmeetings/db/dao/user/UserDao.java
 (original)
+++ 
openmeetings/branches/3.0.x/src/db/java/org/apache/openmeetings/db/dao/user/UserDao.java
 Wed Apr  8 17:11:20 2015
@@ -50,6 +50,7 @@ import org.apache.openmeetings.db.entity
 import org.apache.openmeetings.db.entity.user.User.Right;
 import org.apache.openmeetings.db.entity.user.User.Type;
 import org.apache.openmeetings.db.util.TimezoneUtil;
+import org.apache.openmeetings.db.util.UserHelper;
 import org.apache.openmeetings.util.AuthLevelUtil;
 import org.apache.openmeetings.util.DaoHelper;
 import org.apache.openmeetings.util.OmException;
@@ -144,8 +145,8 @@ public class UserDao implements IDataPro
        }
        
        private void setAdditionalParams(TypedQuery<?> q, Map<String, Object> 
params) {
-               for (String key : params.keySet()) {
-                       q.setParameter(key, params.get(key));
+               for (Map.Entry<String, Object> me: params.entrySet()) {
+                       q.setParameter(me.getKey(), me.getValue());
                }
        }
 
@@ -324,63 +325,66 @@ public class UserDao implements IDataPro
        /**
         * check for duplicates
         * 
-        * @param DataValue
+        * @param login
+        * @param type
+        * @param domainId
+        * @param id
         * @return
         */
-       public boolean checkUserLogin(String login, Long id) {
-               log.debug("checkUserLogin: login = {}, id = {}", login, id);
-               long count = em.createNamedQuery("checkUserLogin", Long.class)
-                               .setParameter("login", login)
-                               .setParameter("id", id == null ? 0 : id)
-                               .getSingleResult();
-               return count == 0;
+       public boolean checkLogin(String login, Type type, Long domainId, Long 
id) {
+               User u = getByLogin(login, type, domainId);
+               return u == null || u.getUser_id().equals(id);
        }
 
        /**
         * Checks if a mail is already taken by someone else
         * 
         * @param email
+        * @param type
+        * @param domainId
+        * @param id
         * @return
         */
-       public boolean checkUserEMail(String email, Long id) {
-               log.debug("checkUserMail: email = {}, id = {}", email, id);
-               if (email == null || email.length() == 0) {
-                       return true;
-               }
-               long count = em.createNamedQuery("checkUserEmail", Long.class)
-                       .setParameter("email", email)
-                       .setParameter("id", id == null ? 0 : id)
-                       .setParameter("type", Type.contact)
-                       .getSingleResult();
-               log.debug("size: " + count);
-
-               return count == 0;
+       public boolean checkEmail(String email, Type type, Long domainId, Long 
id) {
+               log.debug("checkEmail: email = {}, id = {}", email, id);
+               User u = getByEmail(email, type, domainId);
+               return u == null || u.getUser_id().equals(id);
+       }
+       
+       public boolean validLogin(String login) {
+               return !Strings.isEmpty(login) && login.length() >= 
UserHelper.getMinLoginLength(cfgDao);
        }
        
-       public User getByName(String login, Type type) {
-               User us = null;
+       public User getByLogin(String login, Type type, Long domainId) {
+               User u = null;
                try {
-                       us = em.createNamedQuery("getUserByLogin", User.class)
+                       u = em.createNamedQuery("getUserByLogin", User.class)
                                        .setParameter("login", login)
                                        .setParameter("type", type)
+                                       .setParameter("domainId", domainId == 
null ? 0 : domainId)
                                        .getSingleResult();
                } catch (NoResultException ex) {
                }
-               return us;
+               return u;
+       }
+
+       public User getByEmail(String email) {
+               return getByEmail(email, User.Type.user, null);
        }
 
-       public User getUserByEmail(String email) {
-               User us = null;
+       public User getByEmail(String email, User.Type type, Long domainId) {
+               User u = null;
                try {
-                       us = em.createNamedQuery("getUserByEmail", User.class)
+                       u = em.createNamedQuery("getUserByEmail", User.class)
                                        .setParameter("email", email)
-                                       .setParameter("type", User.Type.user)
+                                       .setParameter("type", type)
+                                       .setParameter("domainId", domainId == 
null ? 0 : domainId)
                                        .getSingleResult();
                } catch (NoResultException ex) {
                }
-               return us;
+               return u;
        }
-
+       
        public Object getUserByHash(String hash) {
                if (hash.length() == 0) {
                        return new Long(-5);

Modified: 
openmeetings/branches/3.0.x/src/db/java/org/apache/openmeetings/db/entity/server/OAuthServer.java
URL: 
http://svn.apache.org/viewvc/openmeetings/branches/3.0.x/src/db/java/org/apache/openmeetings/db/entity/server/OAuthServer.java?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/branches/3.0.x/src/db/java/org/apache/openmeetings/db/entity/server/OAuthServer.java
 (original)
+++ 
openmeetings/branches/3.0.x/src/db/java/org/apache/openmeetings/db/entity/server/OAuthServer.java
 Wed Apr  8 17:11:20 2015
@@ -22,6 +22,8 @@ import java.io.Serializable;
 
 import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
@@ -42,8 +44,7 @@ import org.simpleframework.xml.Root;
                @NamedQuery(name = "countOAuthServers", query = "select 
count(s) from OAuthServer s WHERE s.deleted = false") })
 @Root
 public class OAuthServer implements Serializable, IDataProviderEntity {
-
-       private static final long serialVersionUID = -9034438721147720175L;
+       private static final long serialVersionUID = 1L;
 
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -85,7 +86,8 @@ public class OAuthServer implements Seri
        
        @Column(name = "request_method")
        @Element(data = true)
-       private RequestMethod requestTokenMethod;
+       @Enumerated(EnumType.STRING)
+       private RequestMethod requestTokenMethod = RequestMethod.POST;
        
        @Column(name = "request_info_url")
        @Element(data = true)

Modified: 
openmeetings/branches/3.0.x/src/db/java/org/apache/openmeetings/db/entity/user/User.java
URL: 
http://svn.apache.org/viewvc/openmeetings/branches/3.0.x/src/db/java/org/apache/openmeetings/db/entity/user/User.java?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/branches/3.0.x/src/db/java/org/apache/openmeetings/db/entity/user/User.java
 (original)
+++ 
openmeetings/branches/3.0.x/src/db/java/org/apache/openmeetings/db/entity/user/User.java
 Wed Apr  8 17:11:20 2015
@@ -80,12 +80,8 @@ import org.simpleframework.xml.Root;
 @NamedQueries({
        @NamedQuery(name = "getUserById", query = "SELECT u FROM User u WHERE 
u.user_id = :id"),
        @NamedQuery(name = "getUsersByIds", query = "select c from User c where 
c.user_id IN :ids"),
-       @NamedQuery(name = "checkUserLogin", query = "SELECT COUNT(u) FROM User 
u WHERE ((:id > 0 AND u.user_id <> :id) OR (:id = 0)) "
-                       + "AND u.login = :login AND u.deleted = false"),
-       @NamedQuery(name = "checkUserEmail", query = "SELECT COUNT(u) FROM User 
u WHERE ((:id > 0 AND u.user_id <> :id) OR (:id = 0)) "
-                       + "AND u.adresses.email = :email AND u.deleted = false 
AND u.type <> :type"),
-       @NamedQuery(name = "getUserByLogin", query = "SELECT u FROM User u 
WHERE u.deleted = false AND u.type = :type AND u.login = :login"),
-       @NamedQuery(name = "getUserByEmail", query = "SELECT u FROM User u 
WHERE u.deleted = false AND u.type = :type AND u.adresses.email = :email"),
+       @NamedQuery(name = "getUserByLogin", query = "SELECT u FROM User u 
WHERE u.deleted = false AND u.type = :type AND u.login = :login AND ((:domainId 
= 0 AND domainId IS NULL) OR (:domainId > 0 AND domainId = :domainId))"),
+       @NamedQuery(name = "getUserByEmail", query = "SELECT u FROM User u 
WHERE u.deleted = false AND u.type = :type AND u.adresses.email = :email AND 
((:domainId = 0 AND domainId IS NULL) OR (:domainId > 0 AND domainId = 
:domainId))"),
        @NamedQuery(name = "getUserByHash",  query = "SELECT u FROM User u 
WHERE u.deleted = false AND u.type = :type AND u.resethash = :resethash"),
        @NamedQuery(name = "getContactByEmailAndUser", query = "SELECT u FROM 
User u WHERE u.deleted = false AND u.adresses.email = :email AND u.type = :type 
AND u.ownerId = :ownerId"), 
        @NamedQuery(name = "selectMaxFromUsersWithSearch", query = "select 
count(c.user_id) from User c "
@@ -108,7 +104,7 @@ import org.simpleframework.xml.Root;
 @Table(name = "om_user")
 @Root(name = "user")
 public class User implements Serializable, IDataProviderEntity {
-       private static final long serialVersionUID = -2265479712596674065L;
+       private static final long serialVersionUID = 1L;
        
        @XmlType(namespace="org.apache.openmeetings.user.user.right")
        public enum Right {
@@ -131,7 +127,7 @@ public class User implements Serializabl
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id")
-       @Element(data = true)
+       @Element(data = true, name = "user_id")
        private Long user_id;
 
        @Column(name = "age")
@@ -186,7 +182,7 @@ public class User implements Serializabl
        private boolean deleted;
 
        @Column(name = "language_id")
-       @Element(data = true, required = false)
+       @Element(name = "language_id", data = true, required = false)
        private Long language_id;
 
        @Column(name = "resethash")

Modified: 
openmeetings/branches/3.0.x/src/install/java/org/apache/openmeetings/installation/ImportInitvalues.java
URL: 
http://svn.apache.org/viewvc/openmeetings/branches/3.0.x/src/install/java/org/apache/openmeetings/installation/ImportInitvalues.java?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/branches/3.0.x/src/install/java/org/apache/openmeetings/installation/ImportInitvalues.java
 (original)
+++ 
openmeetings/branches/3.0.x/src/install/java/org/apache/openmeetings/installation/ImportInitvalues.java
 Wed Apr  8 17:11:20 2015
@@ -18,6 +18,7 @@
  */
 package org.apache.openmeetings.installation;
 
+import static 
org.apache.openmeetings.db.dao.basic.ConfigurationDao.DEFAULT_APP_NAME;
 import static 
org.apache.openmeetings.db.dao.basic.ConfigurationDao.DEFAULT_MAX_UPLOAD_SIZE;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_APPLICATION_BASE_URL;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_APPOINTMENT_REMINDER_MINUTES;
@@ -46,14 +47,12 @@ import static org.apache.openmeetings.ut
 import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
 
 import java.io.File;
-import java.util.Arrays;
 import java.util.Date;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Set;
 
 import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
 import org.apache.openmeetings.db.dao.basic.ErrorDao;
@@ -67,7 +66,6 @@ import org.apache.openmeetings.db.dao.ro
 import org.apache.openmeetings.db.dao.room.RoomTypeDao;
 import org.apache.openmeetings.db.dao.room.SipDao;
 import org.apache.openmeetings.db.dao.server.OAuth2Dao;
-import org.apache.openmeetings.db.dao.user.IUserManager;
 import org.apache.openmeetings.db.dao.user.OrganisationDao;
 import org.apache.openmeetings.db.dao.user.SalutationDao;
 import org.apache.openmeetings.db.dao.user.StateDao;
@@ -80,6 +78,8 @@ import org.apache.openmeetings.db.entity
 import org.apache.openmeetings.db.entity.server.OAuthServer;
 import org.apache.openmeetings.db.entity.server.OAuthServer.RequestMethod;
 import org.apache.openmeetings.db.entity.user.Organisation;
+import org.apache.openmeetings.db.entity.user.Organisation_Users;
+import org.apache.openmeetings.db.entity.user.User;
 import org.apache.openmeetings.db.entity.user.User.Right;
 import org.apache.openmeetings.db.util.TimezoneUtil;
 import org.apache.openmeetings.util.OmFileHelper;
@@ -94,9 +94,9 @@ public class ImportInitvalues {
        private static final Logger log = 
Red5LoggerFactory.getLogger(ImportInitvalues.class, webAppRootKey);
 
        @Autowired
-       private ConfigurationDao configurationDao;
+       private ConfigurationDao cfgDao;
        @Autowired
-       private UserDao usersDao;
+       private UserDao userDao;
        @Autowired
        private FieldLanguageDao fieldLanguageDaoImpl;
        @Autowired
@@ -126,8 +126,6 @@ public class ImportInitvalues {
        @Autowired
        private OrganisationDao organisationDao;
        @Autowired
-       private IUserManager userManager;
-       @Autowired
        private RoomDao roomDao;
        
        
@@ -250,8 +248,7 @@ public class ImportInitvalues {
 
        public void loadErrorMappingsFromXML() throws Exception {
                SAXReader reader = new SAXReader();
-               Document document = reader.read(new File(
-                               OmFileHelper.getLanguagesDir(), 
OmFileHelper.nameOfErrorFile));
+               Document document = reader.read(new 
File(OmFileHelper.getLanguagesDir(), OmFileHelper.nameOfErrorFile));
 
                Element root = document.getRootElement();
 
@@ -265,24 +262,25 @@ public class ImportInitvalues {
                        Long errortype_id = null;
 
                        for (@SuppressWarnings("unchecked")
-                       Iterator<Element> itSub = row.elementIterator("field"); 
itSub
-                                       .hasNext();) {
+                       Iterator<Element> itSub = row.elementIterator("field"); 
itSub.hasNext();) {
 
                                Element field = itSub.next();
 
                                String name = field.attributeValue("name");
                                String text = field.getText();
                                // System.out.println("NAME | TEXT "+name+" | 
"+text);
-                               if (name.equals("errorvalues_id"))
-                                       errorvalues_id = 
Long.valueOf(text).longValue();
-                               if (name.equals("fieldvalues_id"))
-                                       fieldvalues_id = 
Long.valueOf(text).longValue();
-                               if (name.equals("errortype_id"))
-                                       errortype_id = 
Long.valueOf(text).longValue();
+                               if (name.equals("errorvalues_id")) {
+                                       errorvalues_id = Long.valueOf(text);
+                               }
+                               if (name.equals("fieldvalues_id")) {
+                                       fieldvalues_id = Long.valueOf(text);
+                               }
+                               if (name.equals("errortype_id")) {
+                                       errortype_id = Long.valueOf(text);
+                               }
                        }
 
-                       errorManagement.addErrorValues(errorvalues_id, 
errortype_id,
-                                       fieldvalues_id);
+                       errorManagement.addErrorValues(errorvalues_id, 
errortype_id, fieldvalues_id);
                }
                log.debug("ErrorMappings ADDED");
        }
@@ -297,130 +295,94 @@ public class ImportInitvalues {
        }
 
        public void loadConfiguration(InstallationConfig cfg) {
-               configurationDao
-                               .add(
-                                               CONFIG_CRYPT_KEY,
-                                               cfg.cryptClassName,
-                                               null,
-                                               "This Class is used for 
Authentification-Crypting. "
-                                                               + "Be carefull 
what you do here! If you change it while "
-                                                               + "running 
previous Pass of users will not be workign anymore! "
-                                                               + "for more 
Information see http://openmeetings.apache.org/CustomCryptMechanism.html";);
-
-               configurationDao.add(CONFIG_FRONTEND_REGISTER_KEY,
-                               cfg.allowFrontendRegister, null, "Is user 
register available on login screen");
-               configurationDao.add(CONFIG_SOAP_REGISTER_KEY, "1", null, "Is 
user register available via SOAP/REST");
-               configurationDao.add("default_group_id", "1", null, "");
+               cfgDao.add(CONFIG_CRYPT_KEY, cfg.cryptClassName, null,
+                               "This Class is used for 
Authentification-Crypting. "
+                                               + "Be carefull what you do 
here! If you change it while "
+                                               + "running previous Pass of 
users will not be workign anymore! "
+                                               + "for more Information see 
http://openmeetings.apache.org/CustomCryptMechanism.html";);
+
+               cfgDao.add(CONFIG_FRONTEND_REGISTER_KEY, 
cfg.allowFrontendRegister, null, "Is user register available on login screen");
+               cfgDao.add(CONFIG_SOAP_REGISTER_KEY, "1", null, "Is user 
register available via SOAP/REST");
+               cfgDao.add("default_group_id", "1", null, "");
 
                // this domain_id is the Organisation of users who register 
through the
                // frontend
-               configurationDao.add("default_domain_id", "1", null, "");
+               cfgDao.add("default_domain_id", "1", null, "");
 
 
-               configurationDao.add("smtp_server", cfg.smtpServer, null,
+               cfgDao.add("smtp_server", cfg.smtpServer, null,
                                "this is the smtp server to send messages");
 
-               configurationDao.add("smtp_port", "" + cfg.smtpPort, null,
+               cfgDao.add("smtp_port", "" + cfg.smtpPort, null,
                                "this is the smtp server port normally 25");
 
-               configurationDao.add("system_email_addr", cfg.mailReferer,
-                               null, "all send e-mails by the system will have 
this address");
+               cfgDao.add("system_email_addr", cfg.mailReferer, null, "all 
send e-mails by the system will have this address");
 
-               configurationDao.add("email_username", cfg.mailAuthName,
-                               null, "System auth email username");
+               cfgDao.add("email_username", cfg.mailAuthName, null, "System 
auth email username");
 
-               configurationDao.add("email_userpass", cfg.mailAuthPass,
-                               null, "System auth email password");
+               cfgDao.add("email_userpass", cfg.mailAuthPass, null, "System 
auth email password");
 
-               configurationDao.add("mail.smtp.starttls.enable",
-                               cfg.mailUseTls, null, "Enable TLS 1=true, 
0=false");
+               cfgDao.add("mail.smtp.starttls.enable", cfg.mailUseTls, null, 
"Enable TLS 1=true, 0=false");
                
-               configurationDao.add("mail.smtp.connection.timeout", "30000", 
null,
+               cfgDao.add("mail.smtp.connection.timeout", "30000", null,
                                "Socket connection timeout value in 
milliseconds. Default is 30 seconds (30000).");
                
-               configurationDao.add("mail.smtp.timeout", "30000", null,
+               cfgDao.add("mail.smtp.timeout", "30000", null,
                                "Socket I/O timeout value in milliseconds. 
Default is 30 seconds (30000).");
 
-               configurationDao.add("application.name",
-                               ConfigurationDao.DEFAULT_APP_NAME, null,
-                               "Name of the Browser Title window");
+               cfgDao.add("application.name", DEFAULT_APP_NAME, null, "Name of 
the Browser Title window");
 
                // "1" == "EN"
-               configurationDao.add(CONFIG_DEFAUT_LANG_KEY, cfg.defaultLangId,
-                               null, "Default System Language ID see 
languages.xml");
+               cfgDao.add(CONFIG_DEFAUT_LANG_KEY, cfg.defaultLangId, null, 
"Default System Language ID see languages.xml");
 
-               configurationDao.add("swftools_zoom", "" + cfg.swfZoom, null,
+               cfgDao.add("swftools_zoom", "" + cfg.swfZoom, null,
                                "dpi for conversion of PDF to SWF (should be an 
integer between 50 and  600 with a default value of 100 dpi)");
 
-               configurationDao.add("swftools_jpegquality",
-                               "" + cfg.swfJpegQuality, null,
+               cfgDao.add("swftools_jpegquality", "" + cfg.swfJpegQuality, 
null,
                                "compression quality for conversion of PDF to 
SWF (should be an integer between 1 and 100, with a default value of 85)");
 
-               configurationDao.add("swftools_path", cfg.swfPath, null,
-                               "Path To SWF-Tools");
+               cfgDao.add("swftools_path", cfg.swfPath, null, "Path To 
SWF-Tools");
+
+               cfgDao.add("imagemagick_path", cfg.imageMagicPath, null, "Path 
to ImageMagick tools");
+
+               cfgDao.add("sox_path", cfg.soxPath, null, "Path To SoX-Tools");
+
+               cfgDao.add("ffmpeg_path", cfg.ffmpegPath, null, "Path To 
FFMPEG");
+               cfgDao.add("office.path", cfg.officePath, null,
+                               "The path to OpenOffice/LibreOffice (optional) 
please set this to the real path in case jodconverter is unable to find 
OpenOffice/LibreOffice installation automatically");
+               cfgDao.add("jod.path", cfg.jodPath, null,
+                               "The path to JOD library 
(http://code.google.com/p/jodconverter), configure the path to point to the lib 
directory of JOD that contains also the jodconverter-core-version.jar");
+
+               cfgDao.add(CONFIG_RSS_FEED1_KEY, cfg.urlFeed, null, "Feed URL");
 
-               configurationDao.add("imagemagick_path",
-                               cfg.imageMagicPath, null, "Path to ImageMagick 
tools");
+               cfgDao.add(CONFIG_RSS_FEED2_KEY, cfg.urlFeed2, null, "Feed URL 
2");
 
-               configurationDao.add("sox_path", cfg.soxPath, null,
-                               "Path To SoX-Tools");
+               cfgDao.add("sendEmailAtRegister", cfg.sendEmailAtRegister, null,
+                               "User get a EMail with their Account data. 
Values: 0(No) or 1(Yes)");
 
-               configurationDao.add("ffmpeg_path", cfg.ffmpegPath, null,
-                               "Path To FFMPEG");
-               configurationDao.add(
-                                               "office.path",
-                                               cfg.officePath,
-                                               null,
-                                               "The path to 
OpenOffice/LibreOffice (optional) please set this to the real path in case 
jodconverter is unable to find OpenOffice/LibreOffice installation 
automatically");
-               configurationDao.add(
-                                               "jod.path",
-                                               cfg.jodPath,
-                                               null,
-                                               "The path to JOD library 
(http://code.google.com/p/jodconverter), configure the path to point to the lib 
directory of JOD that contains also the jodconverter-core-version.jar");
-
-               configurationDao.add(CONFIG_RSS_FEED1_KEY, cfg.urlFeed, null,
-                               "Feed URL");
-
-               configurationDao.add(CONFIG_RSS_FEED2_KEY, cfg.urlFeed2, null,
-                               "Feed URL 2");
-
-               configurationDao.add("sendEmailAtRegister", 
cfg.sendEmailAtRegister,
-                                               null,
-                                               "User get a EMail with their 
Account data. Values: 0(No) or 1(Yes)");
-
-               configurationDao.add(
-                                               "sendEmailWithVerficationCode",
-                                               
cfg.sendEmailWithVerficationCode,
-                                               null,
-                                               "User must activate their 
account by clicking on the "
-                                                               + 
"activation-link in the registering Email. Values: 0(No) or 1(Yes) "
-                                                               + "It makes no 
sense to make this(sendEmailWithVerficationCode) 1(Yes) while "
-                                                               + 
"sendEmailAtRegister is 0(No) cause you need"
-                                                               + "to send a 
EMail.");
-               configurationDao.add(
-                                               "default_export_font",
-                                               cfg.defaultExportFont,
-                                               null,
-                                               "The Name of the Font used for 
exporting/render Images from Whiteboard"
-                                                               + "The Font has 
to exist on the Server which runs Red5");
+               cfgDao.add("sendEmailWithVerficationCode", 
cfg.sendEmailWithVerficationCode, null,
+                               "User must activate their account by clicking 
on the "
+                                               + "activation-link in the 
registering Email. Values: 0(No) or 1(Yes) "
+                                               + "It makes no sense to make 
this(sendEmailWithVerficationCode) 1(Yes) while "
+                                               + "sendEmailAtRegister is 0(No) 
cause you need"
+                                               + "to send a EMail.");
+               cfgDao.add("default_export_font", cfg.defaultExportFont, null,
+                               "The Name of the Font used for exporting/render 
Images from Whiteboard"
+                                               + "The Font has to exist on the 
Server which runs Red5");
 
-               configurationDao.add("default.rpc.userid", "" + 1, null,
-                               "The User-Id of the Control User in 
OpenMeetings");
+               cfgDao.add("default.rpc.userid", "" + 1, null, "The User-Id of 
the Control User in OpenMeetings");
 
-               configurationDao.add(CONFIG_APPLICATION_BASE_URL, cfg.baseUrl, 
null, "Base URL your OPenmeetings installation will be accessible at.");
+               cfgDao.add(CONFIG_APPLICATION_BASE_URL, cfg.baseUrl, null, 
"Base URL your OPenmeetings installation will be accessible at.");
                
                // ***************************************
                // ***************************************
                // red5SIP Integration Coniguration Values
                // ***************************************
 
-               configurationDao.add("red5sip.enable", cfg.red5SipEnable,
-                               null, "Enable to enable the red5SIP integration 
");
-               configurationDao.add("red5sip.room_prefix",
-                               cfg.red5SipRoomPrefix, null,
+               cfgDao.add("red5sip.enable", cfg.red5SipEnable, null, "Enable 
to enable the red5SIP integration ");
+               cfgDao.add("red5sip.room_prefix", cfg.red5SipRoomPrefix, null,
                                "Numerical prefix for OM rooms created inside 
the SIP");
-               configurationDao.add("red5sip.exten_context",
-                               cfg.red5SipExtenContext, null,
+               cfgDao.add("red5sip.exten_context", cfg.red5SipExtenContext, 
null,
                                "Enable to enable the red5SIP integration ");
 
                // ***************************************
@@ -428,114 +390,73 @@ public class ImportInitvalues {
                // Timezone settings
                // ***************************************
 
-               configurationDao.add("default.timezone",
-                               cfg.ical_timeZone, null,
-                               "This is the default timezone if nothing is 
specified");
+               cfgDao.add("default.timezone", cfg.ical_timeZone, null, "This 
is the default timezone if nothing is specified");
 
                // ***************************************
                // ***************************************
                // additional settings
                // ***************************************
 
-               configurationDao.add("show.facebook.login", "" + 0, null,
-                               "Show Facebook Login");
-
-               configurationDao.add(CONFIG_SCREENSHARING_QUALITY, "1", null,
+               cfgDao.add(CONFIG_SCREENSHARING_QUALITY, "1", null,
                                "Default selection in ScreenSharing Quality:\n 
0 - bigger frame rate, no resize\n 1 - no resize\n 2 - size == 1/2 of selected 
area\n 3 - size == 3/8 of selected area");
 
-               configurationDao.add(CONFIG_SCREENSHARING_FPS, "10", null, 
"Default selection in ScreenSharing FPS");
-               configurationDao.add(CONFIG_SCREENSHARING_FPS_SHOW, "true", 
null, "Is screensharing FPS should be displayed or not (true/false)");
-               configurationDao.add(CONFIG_SCREENSHARING_ALLOW_REMOTE, "true", 
null, "Is remote control will be enabled while screensharing. Allowing remote 
control will be not possible in case it is set to 'false' (true/false)");
+               cfgDao.add(CONFIG_SCREENSHARING_FPS, "10", null, "Default 
selection in ScreenSharing FPS");
+               cfgDao.add(CONFIG_SCREENSHARING_FPS_SHOW, "true", null, "Is 
screensharing FPS should be displayed or not (true/false)");
+               cfgDao.add(CONFIG_SCREENSHARING_ALLOW_REMOTE, "true", null, "Is 
remote control will be enabled while screensharing. Allowing remote control 
will be not possible in case it is set to 'false' (true/false)");
 
-               configurationDao.add(CONFIG_DASHBOARD_SHOW_MYROOMS_KEY, "1", 
null, "Show My Rooms Tab");
+               cfgDao.add(CONFIG_DASHBOARD_SHOW_MYROOMS_KEY, "1", null, "Show 
My Rooms Tab");
 
-               configurationDao.add("dashboard.show.chat", "1", null, "Show 
Chat Tab");
+               cfgDao.add("dashboard.show.chat", "1", null, "Show Chat Tab");
 
-               configurationDao.add(CONFIG_DASHBOARD_SHOW_RSS_KEY, "0", null, 
"Show RSS Tab");
+               cfgDao.add(CONFIG_DASHBOARD_SHOW_RSS_KEY, "0", null, "Show RSS 
Tab");
 
-               configurationDao
-                               .add(
-                                               "show.whiteboard.draw.status",
-                                               "0",
-                                               null,
-                                               "Display name of the user who 
draw the current object (User Name auto-disapper after 3 seconds.");
+               cfgDao.add("show.whiteboard.draw.status", "0", null,
+                               "Display name of the user who draw the current 
object (User Name auto-disapper after 3 seconds.");
 
-               configurationDao.add(CONFIG_MAX_UPLOAD_SIZE_KEY, ""
-                               + DEFAULT_MAX_UPLOAD_SIZE, null,
+               cfgDao.add(CONFIG_MAX_UPLOAD_SIZE_KEY, "" + 
DEFAULT_MAX_UPLOAD_SIZE, null,
                                "Maximum size of upload file (bytes)"); // 
defaults to 1GB
 
-               configurationDao
-                               .add(
-                                               
CONFIG_APPOINTMENT_REMINDER_MINUTES,
-                                               "15",
-                                               null,
-                                               "The number of minutes before 
reminder emails are send. Set to 0 to disable reminder emails");
+               cfgDao.add(CONFIG_APPOINTMENT_REMINDER_MINUTES, "15", null,
+                               "The number of minutes before reminder emails 
are send. Set to 0 to disable reminder emails");
 
-               configurationDao.add(CONFIG_LOGIN_MIN_LENGTH_KEY, ""
-                               + USER_LOGIN_MINIMUM_LENGTH, null,
+               cfgDao.add(CONFIG_LOGIN_MIN_LENGTH_KEY, "" + 
USER_LOGIN_MINIMUM_LENGTH, null,
                                "Number of chars needed in a user login");
 
-               configurationDao.add(CONFIG_PASS_MIN_LENGTH_KEY, ""
-                               + USER_PASSWORD_MINIMUM_LENGTH, null,
+               cfgDao.add(CONFIG_PASS_MIN_LENGTH_KEY, "" + 
USER_PASSWORD_MINIMUM_LENGTH, null,
                                "Number of chars needed in a user login");
 
-               configurationDao
-                               .add("calendar.conference.rooms.default.size", 
"50",
-                                               null,
-                                               "Default number of participants 
conference room created via calendar");
-
-               configurationDao
-                               .add(
-                                               
"use.old.style.ffmpeg.map.option",
-                                               "0",
-                                               null,
-                                               "specify a 1 if you would like 
to use old FFMPEG -map option with 0.0 instead of 0:0");
+               cfgDao.add("calendar.conference.rooms.default.size", "50", null,
+                               "Default number of participants conference room 
created via calendar");
+
+               cfgDao.add("use.old.style.ffmpeg.map.option", "0", null,
+                               "specify a 1 if you would like to use old 
FFMPEG -map option with 0.0 instead of 0:0");
 
                // give exclusive audio key code
-               configurationDao
-                               .add(
-                                               "exclusive.audio.keycode",
-                                               "123",
-                                               null,
-                                               "A hot key code for the 'give 
exclusive audio' functionality. Keycode 123 is F12");
+               cfgDao.add("exclusive.audio.keycode", "123", null,
+                               "A hot key code for the 'give exclusive audio' 
functionality. Keycode 123 is F12");
                // mute/unmute audio key code
-               configurationDao
-                               .add(
-                                               "mute.keycode",
-                                               "118",
-                                               null,
-                                               "A hot key code for the 
'mute/unmute audio' functionality. Keycode 118 is F7");
+               cfgDao.add("mute.keycode", "118", null,
+                               "A hot key code for the 'mute/unmute audio' 
functionality. Keycode 118 is F7");
                
                // system-wide ldap params
-               configurationDao.add(CONFIG_DEFAULT_LDAP_ID, "0", null,
-                               "Ldap domain selected by default in the login 
screen");
+               cfgDao.add(CONFIG_DEFAULT_LDAP_ID, "0", null, "Ldap domain 
selected by default in the login screen");
 
                // set inviter's email address as ReplyTo in email invitations
-               configurationDao
-                               .add(
-                                               "inviter.email.as.replyto",
-                                               cfg.replyToOrganizer,
-                                               null,
-                                               "Set inviter's email address as 
ReplyTo in email invitations (1 == set, 0 == NOT set)");
-
-               configurationDao.add(CONFIG_DEFAULT_LANDING_ZONE,
-                               "user/dashboard"
-                               , null
+               cfgDao.add("inviter.email.as.replyto", cfg.replyToOrganizer, 
null,
+                               "Set inviter's email address as ReplyTo in 
email invitations (1 == set, 0 == NOT set)");
+
+               cfgDao.add(CONFIG_DEFAULT_LANDING_ZONE, "user/dashboard", null
                                , "Area to be shown to the user after login. 
Possible values are: "
                                        + "user/dashboard, user/calendar, 
user/record, rooms/my, rooms/group, rooms/public, admin/user, admin/connection"
                                        + ", admin/group, admin/room, 
admin/config, admin/lang, admin/ldap, admin/backup, admin/server, 
admin/oauth2");
                
                // oauth2 params
-               configurationDao
-                               .add(
-                                               CONFIG_IGNORE_BAD_SSL,
-                                               "no", 
-                                               null, 
-                                               "Set \"yes\" or \"no\" to 
enable/disable ssl certifications checking for OAuth2");
+               cfgDao.add(CONFIG_IGNORE_BAD_SSL, "no", null, 
+                               "Set \"yes\" or \"no\" to enable/disable ssl 
certifications checking for OAuth2");
 
-               configurationDao.add(CONFIG_REDIRECT_URL_FOR_EXTERNAL_KEY, "", 
null,
+               cfgDao.add(CONFIG_REDIRECT_URL_FOR_EXTERNAL_KEY, "", null,
                                "Users entered the room via invitationHash or 
secureHash will be redirected to this URL on connection lost");
-               configurationDao.add(CONFIG_CALENDAR_FIRST_DAY, "0", null, "The 
day that each week begins. The value must be a number that represents the day 
of the week. Sunday=0, Monday=1, Tuesday=2, etc.");
+               cfgDao.add(CONFIG_CALENDAR_FIRST_DAY, "0", null, "The day that 
each week begins. The value must be a number that represents the day of the 
week. Sunday=0, Monday=1, Tuesday=2, etc.");
                
                log.debug("Configurations ADDED");
        }
@@ -633,11 +554,6 @@ public class ImportInitvalues {
        }
 
        public void loadInitUserAndOrganisation(InstallationConfig cfg) throws 
Exception {
-               Long default_lang_id = Long.parseLong(cfg.defaultLangId);
-               if (default_lang_id == null) {
-                       default_lang_id = 1L;
-               }
-
                // Add default group
                Organisation org = new Organisation();
                org.setName(cfg.group);
@@ -646,20 +562,22 @@ public class ImportInitvalues {
                org.setStarttime(new Date());
                org = organisationDao.update(org, null);
 
-               Set<Right> rights = UserDao.getDefaultRights();
-               rights.add(Right.Admin);
-               rights.add(Right.Soap);
-               Long user_id = userManager.registerUserInit(rights, 
cfg.username, cfg.password, "lastname"
-                               , "firstname", cfg.email, new Date() /* 
age/birthday */, "street", "no", "fax", "zip", 1
-                               , "town", default_lang_id, false /* 
sendWelcomeMessage */
-                               , Arrays.asList(org.getOrganisation_id()), 
"phone", false, false, timezoneUtil.getTimeZone(cfg.ical_timeZone),
-                               false /* forceTimeZoneCheck */, "" /* 
userOffers */, "" /* userSearchs */, false /* showContactData */,
-                               true /* showContactDataToContacts */, null);
+               User u = userDao.getNewUserInstance(null);
+               u.setType(User.Type.user);
+               u.getRights().add(Right.Admin);
+               u.getRights().add(Right.Soap);
+               u.setLogin(cfg.username);
+               u.setFirstname("firstname");
+               u.setLastname("lastname");
+               u.getAdresses().setEmail(cfg.email);
+               u.getOrganisation_users().add(new Organisation_Users(org));
+               
+               u = userDao.update(u, cfg.password, -1);
 
-               log.debug("Installation - User Added user-Id " + user_id);
+               log.debug("Installation - User Added user-Id " + 
u.getUser_id());
 
-               if (user_id < 0) {
-                       throw new Exception("Could not add user user returns a 
negative error message: " + user_id);
+               if (u.getUser_id() == null) {
+                       throw new Exception("Unable to add user");
                }
        }
 
@@ -700,18 +618,16 @@ public class ImportInitvalues {
                Map<Integer, Map<String, Object>> languages = new 
LinkedHashMap<Integer, Map<String, Object>>();
 
                SAXReader reader = new SAXReader();
-               Document document = reader
-                               .read(new File(OmFileHelper.getLanguagesDir(),
-                                               
OmFileHelper.nameOfLanguageFile));
+               File langFile = new File(OmFileHelper.getLanguagesDir(), 
OmFileHelper.nameOfLanguageFile);
+               log.debug("File to load languages from is: " + 
langFile.getCanonicalPath());
 
-               Element root = document.getRootElement();
+               Element root = reader.read(langFile).getRootElement();
 
                for (@SuppressWarnings("unchecked")
                Iterator<Element> it = root.elementIterator("lang"); 
it.hasNext();) {
                        Element item = it.next();
                        String country = item.getText();
-                       Integer id = 
Integer.valueOf(item.attribute("id").getValue())
-                                       .intValue();
+                       Integer id = 
Integer.valueOf(item.attribute("id").getValue());
 
                        String rtl = item.attribute("rightToLeft").getValue();
                        String code = item.attribute("code").getValue();
@@ -802,7 +718,7 @@ public class ImportInitvalues {
                        Element item = (Element) it.next();
                        // log.error(item.getName());
 
-                       Long id = 
Long.valueOf(item.attributeValue("id")).longValue();
+                       Long id = Long.valueOf(item.attributeValue("id"));
                        String name = item.attributeValue("name");
                        String value = "";
 
@@ -870,14 +786,16 @@ public class ImportInitvalues {
                
yandexServer.setIconUrl("http://yandex.st/morda-logo/i/favicon.ico";);
                yandexServer.setClientId("<put your client_id>");
                yandexServer.setClientSecret("<put your client_secret>");
-               yandexServer.setEmailParamName("default_email");
                yandexServer.setEnabled(false);
-               yandexServer.setLoginParamName("default_email");
                
yandexServer.setRequestInfoUrl("https://login.yandex.ru/info?format=json&oauth_token={$access_token}";);
                
yandexServer.setRequestTokenUrl("https://oauth.yandex.ru/token";);
                
yandexServer.setRequestKeyUrl("https://oauth.yandex.ru/authorize?response_type=code&client_id={$client_id}";);
                
yandexServer.setRequestTokenAttributes("grant_type=authorization_code&code={$code}&client_id={$client_id}&client_secret={$client_secret}");
                yandexServer.setRequestTokenMethod(RequestMethod.POST);
+               yandexServer.setLoginParamName("login");
+               yandexServer.setEmailParamName("default_email");
+               yandexServer.setFirstnameParamName("first_name");
+               yandexServer.setLastnameParamName("last_name");
                oauthDao.update(yandexServer, null);
                
                // Google
@@ -907,11 +825,11 @@ public class ImportInitvalues {
                facebookServer.setClientId("<put your client_id>");
                facebookServer.setClientSecret("<put your client_secret>");
                
facebookServer.setRequestKeyUrl("https://www.facebook.com/dialog/oauth?client_id={$client_id}&redirect_uri={$redirect_uri}&scope=email";);
-               
facebookServer.setRequestTokenUrl("https://graph.facebook.com/oauth/access_token";);
+               
facebookServer.setRequestTokenUrl("https://graph.facebook.com/v2.3/oauth/access_token";);
                facebookServer.setRequestTokenMethod(RequestMethod.POST);
                
facebookServer.setRequestTokenAttributes("client_id={$client_id}&redirect_uri={$redirect_uri}&client_secret={$client_secret}&code={$code}");
-               
facebookServer.setRequestInfoUrl("https://graph.facebook.com/me?access_token={$access_token}&fields=username,first_name,last_name,email";);
-               facebookServer.setLoginParamName("username");
+               
facebookServer.setRequestInfoUrl("https://graph.facebook.com/me?access_token={$access_token}&fields=id,first_name,last_name,email";);
+               facebookServer.setLoginParamName("id");
                facebookServer.setEmailParamName("email");
                facebookServer.setFirstnameParamName("first_name");
                facebookServer.setLastnameParamName("last_name");
@@ -933,7 +851,7 @@ public class ImportInitvalues {
 
        public void loadSystem(InstallationConfig cfg, boolean force) throws 
Exception {
                // FIXME dummy check if installation was performed before
-               if (!force && usersDao.count() > 0) {
+               if (!force && userDao.count() > 0) {
                        log.debug("System contains users, no need to install 
data one more time.");
                }
                sipDao.delete();
@@ -970,7 +888,7 @@ public class ImportInitvalues {
 
        public void loadAll(InstallationConfig cfg, boolean force) throws 
Exception {
                // FIXME dummy check if installation was performed before
-               if (!force && usersDao.count() > 0) {
+               if (!force && userDao.count() > 0) {
                        log.debug("System contains users, no need to install 
data one more time.");
                        return;
                }

Modified: 
openmeetings/branches/3.0.x/src/main/java/org/apache/openmeetings/data/user/UserManager.java
URL: 
http://svn.apache.org/viewvc/openmeetings/branches/3.0.x/src/main/java/org/apache/openmeetings/data/user/UserManager.java?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/branches/3.0.x/src/main/java/org/apache/openmeetings/data/user/UserManager.java
 (original)
+++ 
openmeetings/branches/3.0.x/src/main/java/org/apache/openmeetings/data/user/UserManager.java
 Wed Apr  8 17:11:20 2015
@@ -58,6 +58,7 @@ import org.apache.openmeetings.util.Auth
 import org.apache.openmeetings.util.CalendarPatterns;
 import org.apache.openmeetings.util.DaoHelper;
 import org.apache.openmeetings.util.crypt.ManageCryptStyle;
+import org.apache.wicket.util.string.Strings;
 import org.red5.logging.Red5LoggerFactory;
 import org.red5.server.api.scope.IScope;
 import org.slf4j.Logger;
@@ -135,7 +136,6 @@ public class UserManager implements IUse
 
                } catch (Exception ex2) {
                        log.error("[getAllUserByRange] ", ex2);
-                       ex2.printStackTrace();
                }
                return null;
        }
@@ -163,16 +163,14 @@ public class UserManager implements IUse
 
        public Long logout(String SID, long USER_ID) {
                sessiondataDao.updateUser(SID, 0, false, null);
-               return new Long(-12);
+               return -12L;
        }
 
        public List<Userdata> getUserdataDashBoard(Long user_id) {
-               if (user_id.longValue() > 0) {
+               if (user_id != null && user_id.longValue() > 0) {
                        try {
-                               TypedQuery<Userdata> query = em
-                                               .createQuery("select c from 
Userdata as c where c.user_id = :user_id AND c.deleted <> :deleted", 
Userdata.class);
-                               query.setParameter("user_id", 
user_id.longValue());
-                               query.setParameter("deleted", true);
+                               TypedQuery<Userdata> query = 
em.createQuery("select c from Userdata as c where c.user_id = :user_id AND 
c.deleted = false", Userdata.class);
+                               query.setParameter("user_id", user_id);
                                List<Userdata> ll = query.getResultList();
                                return ll;
                        } catch (Exception ex2) {
@@ -184,15 +182,12 @@ public class UserManager implements IUse
 
        public Userdata getUserdataByKey(Long user_id, String DATA_KEY) {
                Userdata userdata = new Userdata();
-               if (user_id.longValue() > 0) {
+               if (user_id != null && user_id.longValue() > 0) {
                        try {
-                               TypedQuery<Userdata> query = em
-                                               .createQuery("select c from 
Userdata as c where c.user_id = :user_id AND c.data_key = :data_key AND 
c.deleted <> :deleted", Userdata.class);
-                               query.setParameter("user_id", 
user_id.longValue());
+                               TypedQuery<Userdata> query = 
em.createQuery("select c from Userdata as c where c.user_id = :user_id AND 
c.data_key = :data_key AND c.deleted = false", Userdata.class);
+                               query.setParameter("user_id", user_id);
                                query.setParameter("data_key", DATA_KEY);
-                               query.setParameter("deleted", true);
-                               for (Iterator<Userdata> it2 = 
query.getResultList().iterator(); it2
-                                               .hasNext();) {
+                               for (Iterator<Userdata> it2 = 
query.getResultList().iterator(); it2.hasNext();) {
                                        userdata = it2.next();
                                }
                        } catch (Exception ex2) {
@@ -213,7 +208,7 @@ public class UserManager implements IUse
                                        .setParameter("DATA_KEY", DATA_KEY)
                                        .setParameter("USER_ID", USER_ID)
                                        .setParameter("DATA", DATA)
-                                       .setParameter("updatetime", new 
Long(-1))
+                                       .setParameter("updatetime", -1L)
                                        .setParameter("Comment", Comment)
                                        .setParameter("DATA_ID", 
DATA_ID).executeUpdate();
                        res = "Success" + updatedEntities;
@@ -231,9 +226,9 @@ public class UserManager implements IUse
                                        + "comment = :comment where user_id= 
:user_id AND data_key = :data_key";
                        int updatedEntities = em.createQuery(hqlUpdate)
                                        .setParameter("data", DATA)
-                                       .setParameter("updatetime", new 
Long(-1))
+                                       .setParameter("updatetime", -1L)
                                        .setParameter("comment", Comment)
-                                       .setParameter("user_id", 
USER_ID.longValue())
+                                       .setParameter("user_id", USER_ID)
                                        .setParameter("data_key", 
DATA_KEY).executeUpdate();
                        res = "Success" + updatedEntities;
                } catch (Exception ex2) {
@@ -251,10 +246,10 @@ public class UserManager implements IUse
                userdata.setStarttime(new Date());
                userdata.setUpdatetime(null);
                userdata.setComment(Comment);
-               userdata.setUser_id(new Long(USER_ID));
+               userdata.setUser_id(USER_ID);
                userdata.setDeleted(false);
                try {
-                       userdata = em.merge(userdata);
+                       em.merge(userdata);
                        ret = "success";
                } catch (Exception ex2) {
                        log.error("addUserdata", ex2);
@@ -330,7 +325,7 @@ public class UserManager implements IUse
                                                sendSMS, sendConfirmation, 
timezoneUtil.getTimeZone(jNameTimeZone), false, "", "", false, true, null);
 
                                if (user_id > 0 && sendConfirmation) {
-                                       return new Long(-40);
+                                       return -40L;
                                }
 
                                return user_id;
@@ -386,8 +381,8 @@ public class UserManager implements IUse
                // Check for required data
                if (login.length() >= getMinLoginLength(configurationDao)) {
                        // Check for duplicates
-                       boolean checkName = usersDao.checkUserLogin(login, 
null);
-                       boolean checkEmail = usersDao.checkUserEMail(email, 
null);
+                       boolean checkName = usersDao.checkLogin(login, 
User.Type.user, null, null);
+                       boolean checkEmail = Strings.isEmpty(email) || 
usersDao.checkEmail(email, User.Type.user, null, null);
                        if (checkName && checkEmail) {
 
                                String link = configurationDao.getBaseUrl();
@@ -402,7 +397,7 @@ public class UserManager implements IUse
                                        String sendMail = 
emailManagement.sendMail(login,
                                                        password, email, link, 
sendConfirmation);
                                        if (!sendMail.equals("success"))
-                                               return new Long(-19);
+                                               return -19L;
                                }
                                Address adr =  usersDao.getAddress(street, zip, 
town, states_id, additionalname, fax, phone, email);
 

Modified: 
openmeetings/branches/3.0.x/src/main/java/org/apache/openmeetings/ldap/LdapLoginManagement.java
URL: 
http://svn.apache.org/viewvc/openmeetings/branches/3.0.x/src/main/java/org/apache/openmeetings/ldap/LdapLoginManagement.java?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/branches/3.0.x/src/main/java/org/apache/openmeetings/ldap/LdapLoginManagement.java
 (original)
+++ 
openmeetings/branches/3.0.x/src/main/java/org/apache/openmeetings/ldap/LdapLoginManagement.java
 Wed Apr  8 17:11:20 2015
@@ -18,7 +18,6 @@
  */
 package org.apache.openmeetings.ldap;
 
-import static 
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_DEFAUT_LANG_KEY;
 import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
 
 import java.io.File;
@@ -26,9 +25,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.Reader;
-import java.util.Date;
 import java.util.Properties;
-import java.util.Set;
 
 import org.apache.directory.api.ldap.model.cursor.CursorLdapReferralException;
 import org.apache.directory.api.ldap.model.cursor.EntryCursor;
@@ -51,7 +48,6 @@ import org.apache.openmeetings.db.dao.us
 import org.apache.openmeetings.db.dao.user.StateDao;
 import org.apache.openmeetings.db.dao.user.UserDao;
 import org.apache.openmeetings.db.entity.server.LdapConfig;
-import org.apache.openmeetings.db.entity.user.Address;
 import org.apache.openmeetings.db.entity.user.Organisation_Users;
 import org.apache.openmeetings.db.entity.user.User;
 import org.apache.openmeetings.db.entity.user.User.Right;
@@ -167,8 +163,12 @@ public class LdapLoginManagement {
         * 
         */
        // 
----------------------------------------------------------------------------------------
-       public User login(String user, String passwd, Long domainId) throws 
OmException {
+       public User login(String login, String passwd, Long domainId) throws 
OmException {
                log.debug("LdapLoginmanagement.doLdapLogin");
+               if (!userDao.validLogin(login)) {
+                       log.error("Invalid login provided");
+                       return null;
+               }
 
                Properties config = new Properties();
                Reader r = null;
@@ -196,7 +196,7 @@ public class LdapLoginManagement {
 
                String ldap_use_lower_case = 
config.getProperty(CONFIGKEY_LDAP_USE_LOWER_CASE, "false");
                if ("true".equals(ldap_use_lower_case)) {
-                       user = user.toLowerCase();
+                       login = login.toLowerCase();
                }
 
                String ldap_auth_type = 
config.getProperty(CONFIGKEY_LDAP_AUTH_TYPE, "");
@@ -261,7 +261,7 @@ public class LdapLoginManagement {
                                {
                                        bindAdmin(conn, ldap_admin_dn, 
ldap_admin_passwd);
                                        Dn baseDn = new 
Dn(config.getProperty(CONFIGKEY_LDAP_SEARCH_BASE, ""));
-                                       String searchQ = 
String.format(config.getProperty(CONFIGKEY_LDAP_SEARCH_QUERY, "%s"), user);
+                                       String searchQ = 
String.format(config.getProperty(CONFIGKEY_LDAP_SEARCH_QUERY, "%s"), login);
                                        SearchScope scope = 
SearchScope.valueOf(config.getProperty(CONFIGKEY_LDAP_SEARCH_SCOPE, 
SearchScope.ONELEVEL.name()));
                                
                                        EntryCursor cursor = new 
EntryCursorImpl(conn.search(
@@ -296,7 +296,7 @@ public class LdapLoginManagement {
                                        break;
                                case SIMPLEBIND:
                                {
-                                       userDn = getUserDn(config, user);
+                                       userDn = getUserDn(config, login);
                                        conn.bind(userDn, passwd);
                                }
                                        break;
@@ -305,13 +305,10 @@ public class LdapLoginManagement {
                                        authenticated = false;
                                        break;
                        }
-                       u = authenticated ? userDao.getByName(user, Type.ldap) 
: userDao.login(user, passwd);
+                       u = authenticated ? userDao.getByLogin(login, 
Type.ldap, domainId) : userDao.login(login, passwd);
                        if (u == null && Provisionning.AUTOCREATE != prov) {
                                log.error("User not found in OM DB and 
Provisionning.AUTOCREATE was not set");
                                throw new OmException(-11L);
-                       } else if (u != null && 
!domainId.equals(u.getDomainId())) {
-                               log.error("User found in OM DB, but domains are 
differ");
-                               throw new OmException(-11L);
                        }
                        if (authenticated && entry == null) {
                                if (useAdminForAttrs) {
@@ -327,20 +324,13 @@ public class LdapLoginManagement {
                                                throw new OmException(-11L);
                                        }
                                        if (u == null) {
-                                               Set<Right> rights = 
UserDao.getDefaultRights();
-                                               rights.remove(Right.Login);
-
-                                               u = new User();
+                                               u = 
userDao.getNewUserInstance(null);
                                                u.setType(Type.ldap);
-                                               u.setRights(rights);
+                                               
u.getRights().remove(Right.Login);
                                                u.setDomainId(domainId);
                                                
u.getOrganisation_users().add(new 
Organisation_Users(orgDao.get(cfgDao.getConfValue("default_domain_id", 
Long.class, "-1"))));
-                                               u.setLogin(user);
-                                               u.setAge(new Date());
+                                               u.setLogin(login);
                                                
u.setShowContactDataToContacts(true);
-                                               u.setAdresses(new Address());
-                                               
u.setLanguage_id(cfgDao.getConfValue(CONFIG_DEFAUT_LANG_KEY, Long.class, "1"));
-                                               u.setSalutations_id(1L);
                                        }
                                        if 
("true".equals(config.getProperty(CONFIGKEY_LDAP_SYNC_PASSWD_OM, ""))) {
                                                u.updatePassword(cfgDao, 
passwd);

Modified: 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/admin/oauth/OAuthForm.java
URL: 
http://svn.apache.org/viewvc/openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/admin/oauth/OAuthForm.java?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/admin/oauth/OAuthForm.java
 (original)
+++ 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/admin/oauth/OAuthForm.java
 Wed Apr  8 17:11:20 2015
@@ -18,8 +18,11 @@
  */
 package org.apache.openmeetings.web.admin.oauth;
 
+import java.util.Arrays;
+
 import org.apache.openmeetings.db.dao.server.OAuth2Dao;
 import org.apache.openmeetings.db.entity.server.OAuthServer;
+import org.apache.openmeetings.db.entity.server.OAuthServer.RequestMethod;
 import org.apache.openmeetings.web.admin.AdminBaseForm;
 import org.apache.openmeetings.web.app.Application;
 import org.apache.openmeetings.web.app.WebSession;
@@ -28,6 +31,8 @@ import org.apache.wicket.ajax.AjaxReques
 import org.apache.wicket.ajax.form.AjaxFormValidatingBehavior;
 import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.markup.html.form.CheckBox;
+import org.apache.wicket.markup.html.form.ChoiceRenderer;
+import org.apache.wicket.markup.html.form.DropDownChoice;
 import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.markup.html.form.RequiredTextField;
 import org.apache.wicket.markup.html.form.TextField;
@@ -55,6 +60,7 @@ public class OAuthForm extends AdminBase
                add(new 
RequiredTextField<String>("requestTokenUrl").setLabel(Model.of(WebSession.getString(1579))));
                add(new 
RequiredTextField<String>("requestTokenAttributes").setLabel(Model.of(WebSession.getString(1586))));
                add(new 
RequiredTextField<String>("requestInfoUrl").setLabel(Model.of(WebSession.getString(1580))));
+               add(new DropDownChoice<RequestMethod>("requestTokenMethod", 
Arrays.asList(RequestMethod.values()), new 
ChoiceRenderer<RequestMethod>("name", "name")));
                add(new 
RequiredTextField<String>("loginParamName").setLabel(Model.of(WebSession.getString(1582))));
                add(new 
RequiredTextField<String>("emailParamName").setLabel(Model.of(WebSession.getString(1583))));
                add(new 
TextField<String>("firstnameParamName").setLabel(Model.of(WebSession.getString(1584))));

Modified: 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/admin/oauth/OAuthPanel.html
URL: 
http://svn.apache.org/viewvc/openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/admin/oauth/OAuthPanel.html?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/admin/oauth/OAuthPanel.html
 (original)
+++ 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/admin/oauth/OAuthPanel.html
 Wed Apr  8 17:11:20 2015
@@ -88,6 +88,9 @@
                                                                
<label><wicket:ommessage key="1580" /></label><input type="text" 
wicket:id="requestInfoUrl"/>
                                                        </div>
                                                        <div 
class="formelement">
+                                                               <label>Request 
method</label><select wicket:id="requestTokenMethod"></select>
+                                                       </div>
+                                                       <div 
class="formelement">
                                                                
<label><wicket:ommessage key="1582" /></label><input type="text" 
wicket:id="loginParamName"/>
                                                        </div>
                                                        <div 
class="formelement">

Modified: 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/admin/users/UserForm.java
URL: 
http://svn.apache.org/viewvc/openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/admin/users/UserForm.java?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/admin/users/UserForm.java
 (original)
+++ 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/admin/users/UserForm.java
 Wed Apr  8 17:11:20 2015
@@ -131,7 +131,7 @@ public class UserForm extends AdminBaseF
                if (user.getUser_id() != null) {
                        user = getBean(UserDao.class).get(user.getUser_id());
                } else {
-                       user = new User();
+                       user = getBean(UserDao.class).getNewUserInstance(null);
                }
                setModelObject(user);
                update(target);
@@ -249,7 +249,8 @@ public class UserForm extends AdminBaseF
        
        @Override
        protected void onValidate() {
-               
if(!getBean(UserDao.class).checkUserLogin(login.getConvertedInput(), 
getModelObject().getUser_id())) {
+               User u = getModelObject();
+               
if(!getBean(UserDao.class).checkLogin(login.getConvertedInput(), u.getType(), 
u.getDomainId(), u.getUser_id())) {
                        error(WebSession.getString(105));
                }
        }

Modified: 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/app/WebSession.java
URL: 
http://svn.apache.org/viewvc/openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/app/WebSession.java?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/app/WebSession.java
 (original)
+++ 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/app/WebSession.java
 Wed Apr  8 17:11:20 2015
@@ -266,7 +266,7 @@ public class WebSession extends Abstract
                                        break;
                                case oauth:
                                        // we did all the checks at this stage, 
just set the user
-                                       u = 
getBean(UserDao.class).getByName(login, Type.oauth);
+                                       u = 
getBean(UserDao.class).getByLogin(login, Type.oauth, domainId);
                                        break;
                                default:
                                        throw new OmException(-1L);

Modified: 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/common/GeneralUserForm.java
URL: 
http://svn.apache.org/viewvc/openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/common/GeneralUserForm.java?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/common/GeneralUserForm.java
 (original)
+++ 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/common/GeneralUserForm.java
 Wed Apr  8 17:11:20 2015
@@ -190,7 +190,8 @@ public class GeneralUserForm extends For
        
        @Override
        protected void onValidate() {
-               
if(!getBean(UserDao.class).checkUserEMail(email.getConvertedInput(), 
getModelObject().getUser_id())) {
+               User u = getModelObject();
+               
if(!getBean(UserDao.class).checkEmail(email.getConvertedInput(), u.getType(), 
u.getDomainId(), u.getUser_id())) {
                        error(WebSession.getString(1000));
                }
                super.onValidate();

Modified: 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/ForgetPasswordDialog.java
URL: 
http://svn.apache.org/viewvc/openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/ForgetPasswordDialog.java?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/ForgetPasswordDialog.java
 (original)
+++ 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/ForgetPasswordDialog.java
 Wed Apr  8 17:11:20 2015
@@ -122,10 +122,10 @@ public class ForgetPasswordDialog extend
                                UserDao dao = getBean(UserDao.class);
                                String n = nameField.getConvertedInput();
                                if (n != null) {
-                                       if (type == Type.email && null == 
dao.getUserByEmail(n)) {
+                                       if (type == Type.email && null == 
dao.getByEmail(n)) {
                                                
error(WebSession.getString(318));
                                        }
-                                       if (type == Type.login && null == 
dao.getByName(n, User.Type.user)) {
+                                       if (type == Type.login && null == 
dao.getByLogin(n, User.Type.user, null)) {
                                                
error(WebSession.getString(320));
                                        }
                                }
@@ -214,7 +214,7 @@ public class ForgetPasswordDialog extend
                        // check if Mail given
                        if (email.length() > 0) {
                                // log.debug("getAdresses_id 
"+addr_e.getAdresses_id());
-                               User us = userDao.getUserByEmail(email);
+                               User us = userDao.getByEmail(email);
                                if (us != null) {
                                        sendHashByUser(us, appLink, userDao);
                                        return new Long(-4);
@@ -222,7 +222,7 @@ public class ForgetPasswordDialog extend
                                        return new Long(-9);
                                }
                        } else if (username.length() > 0) {
-                               User us = userDao.getByName(username, 
User.Type.user);
+                               User us = userDao.getByLogin(username, 
User.Type.user, null);
                                if (us != null) {
                                        sendHashByUser(us, appLink, userDao);
                                        return new Long(-4);

Modified: 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/RegisterDialog.java
URL: 
http://svn.apache.org/viewvc/openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/RegisterDialog.java?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/RegisterDialog.java
 (original)
+++ 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/RegisterDialog.java
 Wed Apr  8 17:11:20 2015
@@ -37,6 +37,7 @@ import org.apache.openmeetings.db.dao.us
 import org.apache.openmeetings.db.dao.user.UserDao;
 import org.apache.openmeetings.db.entity.label.FieldLanguage;
 import org.apache.openmeetings.db.entity.user.State;
+import org.apache.openmeetings.db.entity.user.User;
 import org.apache.openmeetings.util.CalendarPatterns;
 import org.apache.openmeetings.util.crypt.ManageCryptStyle;
 import org.apache.openmeetings.web.app.WebSession;
@@ -281,10 +282,10 @@ public class RegisterDialog extends Abst
                                        || 
!passwordField.getConvertedInput().equals(confirmPassword.getConvertedInput())) 
{
                                error(WebSession.getString(232));
                        }
-                       if 
(!getBean(UserDao.class).checkUserEMail(emailField.getConvertedInput(), null)) {
+                       if 
(!getBean(UserDao.class).checkEmail(emailField.getConvertedInput(), 
User.Type.user, null, null)) {
                                error(WebSession.getString(1000));
                        }
-                       if 
(!getBean(UserDao.class).checkUserLogin(loginField.getConvertedInput(), null)) {
+                       if 
(!getBean(UserDao.class).checkLogin(loginField.getConvertedInput(), 
User.Type.user, null, null)) {
                                error(WebSession.getString(105));
                        }
                }

Modified: 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/SignInDialog.java
URL: 
http://svn.apache.org/viewvc/openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/SignInDialog.java?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/SignInDialog.java
 (original)
+++ 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/SignInDialog.java
 Wed Apr  8 17:11:20 2015
@@ -162,7 +162,6 @@ public class SignInDialog extends Abstra
        public Form<String> getForm() {
                return form;
        }
-       // TODO Auto-generated method stub
        
        private void shake(AjaxRequestTarget target) {
                JQueryEffectBehavior shake = new JQueryEffectBehavior("#" + 
getMarkupId(), "shake");
@@ -232,7 +231,7 @@ public class SignInDialog extends Abstra
                                .add(new DropDownChoice<LdapConfig>("domain", 
new PropertyModel<LdapConfig>(SignInDialog.this, "domain")
                                                , ldaps, new 
ChoiceRenderer<LdapConfig>("name", "ldapConfigId"))).setVisible(ldaps.size() > 
1));
                        add(new CheckBox("rememberMe", new 
PropertyModel<Boolean>(SignInDialog.this, 
"rememberMe")).setOutputMarkupId(true));
-                       add(new AjaxButton("submit") { //FAKE button so 
"submit-on-enter" works as expected
+                       AjaxButton ab = new AjaxButton("submit") { //FAKE 
button so "submit-on-enter" works as expected
                                private static final long serialVersionUID = 1L;
 
                                @Override
@@ -244,7 +243,9 @@ public class SignInDialog extends Abstra
                                protected void onError(AjaxRequestTarget 
target, Form<?> form) {
                                        SignInDialog.this.onError(target);
                                }
-                       });
+                       };
+                       add(ab);
+                       setDefaultButton(ab);
                        add(new AjaxLink<Void>("forget") {
                                private static final long serialVersionUID = 1L;
 

Modified: 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/SignInPage.java
URL: 
http://svn.apache.org/viewvc/openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/SignInPage.java?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/SignInPage.java
 (original)
+++ 
openmeetings/branches/3.0.x/src/web/java/org/apache/openmeetings/web/pages/auth/SignInPage.java
 Wed Apr  8 17:11:20 2015
@@ -51,10 +51,12 @@ import javax.net.ssl.X509TrustManager;
 import org.apache.commons.io.IOUtils;
 import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
 import org.apache.openmeetings.db.dao.server.OAuth2Dao;
-import org.apache.openmeetings.db.dao.user.IUserManager;
+import org.apache.openmeetings.db.dao.user.OrganisationDao;
 import org.apache.openmeetings.db.dao.user.UserDao;
 import org.apache.openmeetings.db.entity.server.OAuthServer;
+import org.apache.openmeetings.db.entity.user.Organisation_Users;
 import org.apache.openmeetings.db.entity.user.User;
+import org.apache.openmeetings.db.entity.user.User.Right;
 import org.apache.openmeetings.db.entity.user.User.Type;
 import org.apache.openmeetings.web.app.Application;
 import org.apache.openmeetings.web.app.WebSession;
@@ -324,44 +326,48 @@ public class SignInPage extends BaseInit
        
        private void loginViaOAuth2(Map<String, String> params, long serverId) 
throws IOException, NoSuchAlgorithmException {
                UserDao userDao = getBean(UserDao.class);
-               IUserManager userManager = getBean(IUserManager.class); 
-               ConfigurationDao configurationDao = 
getBean(ConfigurationDao.class);
+               ConfigurationDao cfgDao = getBean(ConfigurationDao.class);
                String login = params.get("login");
                String email = params.get("email");
                String lastname = params.get("lastname");
                String firstname = params.get("firstname");
-               if (firstname == null) firstname = "";
-               if (lastname == null) lastname = "";
-               User user = userDao.getByName(login, Type.oauth);
+               if (firstname == null) {
+                       firstname = "";
+               }
+               if (lastname == null) {
+                       lastname = "";
+               }
+               if (!userDao.validLogin(login)) {
+                       log.error("Invalid login, please check parameters");
+                       return;
+               }
+               User u = userDao.getByLogin(login, Type.oauth, serverId);
+               if (!userDao.checkEmail(email, Type.oauth, serverId, u == null 
? null : u.getUser_id())) {
+                       log.error("Another user with the same email exists");
+                       return;
+               }
                // generate random password
                byte[] rawPass = new byte[16];
                Random rnd = new Random();
-               for (int i = 0; i < 16; i++) {
-                       rawPass[i] = (byte) (97 + rnd.nextInt(25));
+               for (int i = 0; i < 25; i++) {
+                       rawPass[i] = (byte) ('!' + rnd.nextInt(93));
                }
-               String pass = new String(rawPass);
+               String pass = new String(rawPass, "UTF-8");
                // check if the user already exists and register new one if 
it's needed
-               if (user == null) {
-                       Integer defaultlangId = 
Integer.valueOf(configurationDao.getConfValue("default_lang_id", String.class, 
"1"));
-                       String defaultTimezone = 
configurationDao.getConfValue("default.timezone", String.class, "");           
-                       Long res = userManager.registerUserNoEmail(login, pass, 
lastname, firstname, email, null, null, 
-                                       null, null, null, 0, null, 
defaultlangId, null, false, true, defaultTimezone);
-                       if (res == null || res < 0) {
-                               throw new RuntimeException("Couldn't register 
new oauth user");
-                       }
-                       user = userDao.get(res);
-                       user.setType(Type.oauth);
-                       user.setDomainId(serverId);
-                       userDao.update(user, null);
-               } else { // just change password
-                       // check user type before changing password, it must be 
match oauthServerId
-                       if (user.getDomainId() == null || serverId != 
user.getDomainId()) {
-                               log.error("User already registered! with 
different OAuth server");
-                               return;
-                       }
-                       user.setLastlogin(new Date());
-                       user = userDao.update(user, pass, -1);
+               if (u == null) {
+                       u = userDao.getNewUserInstance(null);
+                       u.setType(Type.oauth);
+                       u.getRights().remove(Right.Login);;
+                       u.setDomainId(serverId);
+                       u.getOrganisation_users().add(new 
Organisation_Users(getBean(OrganisationDao.class).get(cfgDao.getConfValue("default_domain_id",
 Long.class, "-1"))));
+                       u.setLogin(login);
+                       u.setShowContactDataToContacts(true);
+                       u.setLastname(lastname);
+                       u.setFirstname(firstname);
+                       u.getAdresses().setEmail(email);
                }
+               u.setLastlogin(new Date());
+               u = userDao.update(u, pass, -1);
                
                if (WebSession.get().signIn(login, pass, Type.oauth, serverId)) 
{
                        setResponsePage(Application.get().getHomePage());

Modified: 
openmeetings/trunk/singlewebapp/openmeetings-core/src/main/java/org/apache/openmeetings/core/ldap/LdapLoginManagement.java
URL: 
http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/openmeetings-core/src/main/java/org/apache/openmeetings/core/ldap/LdapLoginManagement.java?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/trunk/singlewebapp/openmeetings-core/src/main/java/org/apache/openmeetings/core/ldap/LdapLoginManagement.java
 (original)
+++ 
openmeetings/trunk/singlewebapp/openmeetings-core/src/main/java/org/apache/openmeetings/core/ldap/LdapLoginManagement.java
 Wed Apr  8 17:11:20 2015
@@ -18,7 +18,6 @@
  */
 package org.apache.openmeetings.core.ldap;
 
-import static 
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_DEFAUT_LANG_KEY;
 import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
 
 import java.io.File;
@@ -26,9 +25,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.Reader;
-import java.util.Date;
 import java.util.Properties;
-import java.util.Set;
 
 import org.apache.directory.api.ldap.model.cursor.CursorLdapReferralException;
 import org.apache.directory.api.ldap.model.cursor.EntryCursor;
@@ -51,7 +48,6 @@ import org.apache.openmeetings.db.dao.us
 import org.apache.openmeetings.db.dao.user.StateDao;
 import org.apache.openmeetings.db.dao.user.UserDao;
 import org.apache.openmeetings.db.entity.server.LdapConfig;
-import org.apache.openmeetings.db.entity.user.Address;
 import org.apache.openmeetings.db.entity.user.OrganisationUser;
 import org.apache.openmeetings.db.entity.user.User;
 import org.apache.openmeetings.db.entity.user.User.Right;
@@ -167,8 +163,12 @@ public class LdapLoginManagement {
         * 
         */
        // 
----------------------------------------------------------------------------------------
-       public User login(String user, String passwd, Long domainId) throws 
OmException {
+       public User login(String login, String passwd, Long domainId) throws 
OmException {
                log.debug("LdapLoginmanagement.doLdapLogin");
+               if (!userDao.validLogin(login)) {
+                       log.error("Invalid login provided");
+                       return null;
+               }
 
                Properties config = new Properties();
                Reader r = null;
@@ -196,7 +196,7 @@ public class LdapLoginManagement {
 
                String ldap_use_lower_case = 
config.getProperty(CONFIGKEY_LDAP_USE_LOWER_CASE, "false");
                if ("true".equals(ldap_use_lower_case)) {
-                       user = user.toLowerCase();
+                       login = login.toLowerCase();
                }
 
                String ldap_auth_type = 
config.getProperty(CONFIGKEY_LDAP_AUTH_TYPE, "");
@@ -261,7 +261,7 @@ public class LdapLoginManagement {
                                {
                                        bindAdmin(conn, ldap_admin_dn, 
ldap_admin_passwd);
                                        Dn baseDn = new 
Dn(config.getProperty(CONFIGKEY_LDAP_SEARCH_BASE, ""));
-                                       String searchQ = 
String.format(config.getProperty(CONFIGKEY_LDAP_SEARCH_QUERY, "%s"), user);
+                                       String searchQ = 
String.format(config.getProperty(CONFIGKEY_LDAP_SEARCH_QUERY, "%s"), login);
                                        SearchScope scope = 
SearchScope.valueOf(config.getProperty(CONFIGKEY_LDAP_SEARCH_SCOPE, 
SearchScope.ONELEVEL.name()));
                                
                                        EntryCursor cursor = new 
EntryCursorImpl(conn.search(
@@ -296,7 +296,7 @@ public class LdapLoginManagement {
                                        break;
                                case SIMPLEBIND:
                                {
-                                       userDn = getUserDn(config, user);
+                                       userDn = getUserDn(config, login);
                                        conn.bind(userDn, passwd);
                                }
                                        break;
@@ -305,13 +305,10 @@ public class LdapLoginManagement {
                                        authenticated = false;
                                        break;
                        }
-                       u = authenticated ? userDao.getByName(user, Type.ldap) 
: userDao.login(user, passwd);
+                       u = authenticated ? userDao.getByLogin(login, 
Type.ldap, domainId) : userDao.login(login, passwd);
                        if (u == null && Provisionning.AUTOCREATE != prov) {
                                log.error("User not found in OM DB and 
Provisionning.AUTOCREATE was not set");
                                throw new OmException(-11L);
-                       } else if (u != null && 
!domainId.equals(u.getDomainId())) {
-                               log.error("User found in OM DB, but domains are 
differ");
-                               throw new OmException(-11L);
                        }
                        if (authenticated && entry == null) {
                                if (useAdminForAttrs) {
@@ -327,20 +324,13 @@ public class LdapLoginManagement {
                                                throw new OmException(-11L);
                                        }
                                        if (u == null) {
-                                               Set<Right> rights = 
UserDao.getDefaultRights();
-                                               rights.remove(Right.Login);
-
-                                               u = new User();
+                                               u = 
userDao.getNewUserInstance(null);
                                                u.setType(Type.ldap);
-                                               u.setRights(rights);
+                                               
u.getRights().remove(Right.Login);
                                                u.setDomainId(domainId);
                                                
u.getOrganisationUsers().add(new 
OrganisationUser(orgDao.get(cfgDao.getConfValue("default_domain_id", 
Long.class, "-1"))));
-                                               u.setLogin(user);
-                                               u.setAge(new Date());
+                                               u.setLogin(login);
                                                
u.setShowContactDataToContacts(true);
-                                               u.setAdresses(new Address());
-                                               
u.setLanguageId(cfgDao.getConfValue(CONFIG_DEFAUT_LANG_KEY, Long.class, "1"));
-                                               u.setSalutations_id(1L);
                                        }
                                        if 
("true".equals(config.getProperty(CONFIGKEY_LDAP_SYNC_PASSWD_OM, ""))) {
                                                u.updatePassword(cfgDao, 
passwd);

Modified: 
openmeetings/trunk/singlewebapp/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
URL: 
http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/trunk/singlewebapp/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
 (original)
+++ 
openmeetings/trunk/singlewebapp/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
 Wed Apr  8 17:11:20 2015
@@ -51,6 +51,7 @@ import org.apache.openmeetings.db.entity
 import org.apache.openmeetings.db.entity.user.User.Type;
 import org.apache.openmeetings.db.util.AuthLevelUtil;
 import org.apache.openmeetings.db.util.TimezoneUtil;
+import org.apache.openmeetings.db.util.UserHelper;
 import org.apache.openmeetings.util.DaoHelper;
 import org.apache.openmeetings.util.OmException;
 import org.apache.openmeetings.util.crypt.ManageCryptStyle;
@@ -324,61 +325,64 @@ public class UserDao implements IDataPro
        /**
         * check for duplicates
         * 
-        * @param DataValue
+        * @param login
+        * @param type
+        * @param domainId
+        * @param id
         * @return
         */
-       public boolean checkUserLogin(String login, Long id) {
-               log.debug("checkUserLogin: login = {}, id = {}", login, id);
-               long count = em.createNamedQuery("checkUserLogin", Long.class)
-                               .setParameter("login", login)
-                               .setParameter("id", id == null ? 0L : id)
-                               .getSingleResult();
-               return count == 0L;
+       public boolean checkLogin(String login, Type type, Long domainId, Long 
id) {
+               User u = getByLogin(login, type, domainId);
+               return u == null || u.getId().equals(id);
        }
 
        /**
         * Checks if a mail is already taken by someone else
         * 
         * @param email
+        * @param type
+        * @param domainId
+        * @param id
         * @return
         */
-       public boolean checkUserEMail(String email, Long id) {
-               log.debug("checkUserMail: email = {}, id = {}", email, id);
-               if (email == null || email.length() == 0) {
-                       return true;
-               }
-               long count = em.createNamedQuery("checkUserEmail", Long.class)
-                       .setParameter("email", email)
-                       .setParameter("id", id == null ? 0L : id)
-                       .setParameter("type", Type.contact)
-                       .getSingleResult();
-               log.debug("size: " + count);
+       public boolean checkEmail(String email, Type type, Long domainId, Long 
id) {
+               log.debug("checkEmail: email = {}, id = {}", email, id);
+               User u = getByEmail(email, type, domainId);
+               return u == null || u.getId().equals(id);
+               }
 
-               return count == 0L;
+       public boolean validLogin(String login) {
+               return !Strings.isEmpty(login) && login.length() >= 
UserHelper.getMinLoginLength(cfgDao);
        }
        
-       public User getByName(String login, Type type) {
-               User us = null;
+       public User getByLogin(String login, Type type, Long domainId) {
+               User u = null;
                try {
-                       us = em.createNamedQuery("getUserByLogin", User.class)
+                       u = em.createNamedQuery("getUserByLogin", User.class)
                                        .setParameter("login", login)
                                        .setParameter("type", type)
+                                       .setParameter("domainId", domainId == 
null ? 0 : domainId)
                                        .getSingleResult();
                } catch (NoResultException ex) {
                }
-               return us;
+               return u;
+       }
+
+       public User getByEmail(String email) {
+               return getByEmail(email, User.Type.user, null);
        }
 
-       public User getUserByEmail(String email) {
-               User us = null;
+       public User getByEmail(String email, User.Type type, Long domainId) {
+               User u = null;
                try {
-                       us = em.createNamedQuery("getUserByEmail", User.class)
+                       u = em.createNamedQuery("getUserByEmail", User.class)
                                        .setParameter("email", email)
-                                       .setParameter("type", User.Type.user)
+                                       .setParameter("type", type)
+                                       .setParameter("domainId", domainId == 
null ? 0 : domainId)
                                        .getSingleResult();
                } catch (NoResultException ex) {
                }
-               return us;
+               return u;
        }
 
        public Object getUserByHash(String hash) {

Modified: 
openmeetings/trunk/singlewebapp/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/server/OAuthServer.java
URL: 
http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/server/OAuthServer.java?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/trunk/singlewebapp/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/server/OAuthServer.java
 (original)
+++ 
openmeetings/trunk/singlewebapp/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/server/OAuthServer.java
 Wed Apr  8 17:11:20 2015
@@ -20,6 +20,8 @@ package org.apache.openmeetings.db.entit
 
 import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
@@ -40,7 +42,6 @@ import org.simpleframework.xml.Root;
                @NamedQuery(name = "countOAuthServers", query = "select 
count(s) from OAuthServer s WHERE s.deleted = false") })
 @Root
 public class OAuthServer implements IDataProviderEntity {
-
        private static final long serialVersionUID = 1L;
 
        @Id
@@ -83,7 +84,8 @@ public class OAuthServer implements IDat
        
        @Column(name = "request_method")
        @Element(data = true)
-       private RequestMethod requestTokenMethod;
+       @Enumerated(EnumType.STRING)
+       private RequestMethod requestTokenMethod = RequestMethod.POST;
        
        @Column(name = "request_info_url")
        @Element(data = true)

Modified: 
openmeetings/trunk/singlewebapp/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/User.java
URL: 
http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/User.java?rev=1672122&r1=1672121&r2=1672122&view=diff
==============================================================================
--- 
openmeetings/trunk/singlewebapp/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/User.java
 (original)
+++ 
openmeetings/trunk/singlewebapp/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/User.java
 Wed Apr  8 17:11:20 2015
@@ -79,12 +79,8 @@ import org.simpleframework.xml.Root;
 @NamedQueries({
        @NamedQuery(name = "getUserById", query = "SELECT u FROM User u WHERE 
u.id = :id"),
        @NamedQuery(name = "getUsersByIds", query = "select c from User c where 
c.id IN :ids"),
-       @NamedQuery(name = "checkUserLogin", query = "SELECT COUNT(u) FROM User 
u WHERE ((:id > 0 AND u.id <> :id) OR (:id = 0)) "
-                       + "AND u.login = :login AND u.deleted = false"),
-       @NamedQuery(name = "checkUserEmail", query = "SELECT COUNT(u) FROM User 
u WHERE ((:id > 0 AND u.id <> :id) OR (:id = 0)) "
-                       + "AND u.adresses.email = :email AND u.deleted = false 
AND u.type <> :type"),
-       @NamedQuery(name = "getUserByLogin", query = "SELECT u FROM User u 
WHERE u.deleted = false AND u.type = :type AND u.login = :login"),
-       @NamedQuery(name = "getUserByEmail", query = "SELECT u FROM User u 
WHERE u.deleted = false AND u.type = :type AND u.adresses.email = :email"),
+       @NamedQuery(name = "getUserByLogin", query = "SELECT u FROM User u 
WHERE u.deleted = false AND u.type = :type AND u.login = :login AND ((:domainId 
= 0 AND domainId IS NULL) OR (:domainId > 0 AND domainId = :domainId))"),
+       @NamedQuery(name = "getUserByEmail", query = "SELECT u FROM User u 
WHERE u.deleted = false AND u.type = :type AND u.adresses.email = :email AND 
((:domainId = 0 AND domainId IS NULL) OR (:domainId > 0 AND domainId = 
:domainId))"),
        @NamedQuery(name = "getUserByHash",  query = "SELECT u FROM User u 
WHERE u.deleted = false AND u.type = :type AND u.resethash = :resethash"),
        @NamedQuery(name = "getContactByEmailAndUser", query = "SELECT u FROM 
User u WHERE u.deleted = false AND u.adresses.email = :email AND u.type = :type 
AND u.ownerId = :ownerId"), 
        @NamedQuery(name = "selectMaxFromUsersWithSearch", query = "select 
count(c.id) from User c "


Reply via email to