use of org.apache.openmeetings.util.OmException in project openmeetings by apache.
the class TestUserGroup method addUserWithoutGroup.
@Test
public void addUserWithoutGroup() throws Exception {
String uuid = UUID.randomUUID().toString();
User u = getUser(uuid);
u = userDao.update(u, null);
assertNotNull("User successfully created", u.getId());
checkEmptyGroup("dao.get()", userDao.get(u.getId()));
try {
checkEmptyGroup("dao.login()", userDao.login(u.getAddress().getEmail(), createPass()));
fail("User with no Group is unable to login");
} catch (OmException e) {
assertTrue("Expected Om Exception", "error.nogroup".equals(e.getKey()));
}
checkEmptyGroup("dao.getByLogin(user)", userDao.getByLogin(u.getLogin(), u.getType(), u.getDomainId()));
}
use of org.apache.openmeetings.util.OmException in project openmeetings by apache.
the class MobileService method loginUser.
public Map<String, Object> loginUser(String login, String password) {
Map<String, Object> result = getResult();
try {
User u = userDao.login(login, password);
result = login(u, result);
} catch (OmException e) {
result.put(PARAM_STATUS, e.getKey());
} catch (Exception e) {
log.error("[loginUser]", e);
}
return result;
}
use of org.apache.openmeetings.util.OmException in project openmeetings by apache.
the class LdapLoginManager method importUsers.
public void importUsers(Long domainId, boolean print) throws OmException {
try (LdapWorker w = new LdapWorker(domainId)) {
bindAdmin(w.conn, w.options);
Dn baseDn = new Dn(w.options.searchBase);
try (EntryCursor cursor = new EntryCursorImpl(w.conn.search(new SearchRequestImpl().setBase(baseDn).setFilter(w.options.importQuery).setScope(w.options.scope).addAttributes("*").setDerefAliases(w.options.derefMode)))) {
while (cursor.next()) {
try {
Entry e = cursor.get();
User u = userDao.getByLogin(getLogin(w.config, e), Type.ldap, domainId);
u = w.getUser(e, u);
if (print) {
log.info("Going to import user: {}", u);
} else {
userDao.update(u, null);
log.info("User {}, was imported", u);
}
} catch (CursorLdapReferralException cle) {
log.warn("Referral LDAP entry found, ignore it");
}
}
}
} catch (LdapAuthenticationException ae) {
log.error("Not authenticated.", ae);
throw BAD_CREDENTIALS;
} catch (OmException e) {
throw e;
} catch (Exception e) {
log.error("Unexpected exception.", e);
throw new OmException(e);
}
}
use of org.apache.openmeetings.util.OmException in project openmeetings by apache.
the class AbstractWicketTester method login.
public void login(String login, String password) {
WebSession s = WebSession.get();
try {
if (login != null && password != null) {
s.signIn(login, password, Type.user, null);
} else {
s.signIn(adminUsername, userpass, Type.user, null);
}
} catch (OmException e) {
fail(e.getMessage());
}
assertTrue("Web session is not signed in for user: " + (login != null ? login : adminUsername), s.isSignedIn());
}
use of org.apache.openmeetings.util.OmException in project openmeetings by apache.
the class UserWebService method login.
/**
* @param user - login or email of Openmeetings user with admin or SOAP-rights
* @param pass - password
*
* @return - {@link ServiceResult} with error code or SID and userId
*/
@WebMethod
@GET
@Path("/login")
public ServiceResult login(@WebParam(name = "user") @QueryParam("user") String user, @WebParam(name = "pass") @QueryParam("pass") String pass) {
try {
log.debug("Login user");
User u = userDao.login(user, pass);
if (u == null) {
return new ServiceResult("error.bad.credentials", Type.ERROR);
}
Sessiondata sd = sessionDao.create(u.getId(), u.getLanguageId());
log.debug("Login user: {}", u.getId());
return new ServiceResult(sd.getSessionId(), Type.SUCCESS);
} catch (OmException oe) {
return oe.getKey() == null ? UNKNOWN : new ServiceResult(oe.getKey(), Type.ERROR);
} catch (Exception err) {
log.error("[login]", err);
return UNKNOWN;
}
}
Aggregations