Search in sources :

Example 6 with WebSession

use of org.apache.openmeetings.web.app.WebSession 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());
}
Also used : WebSession(org.apache.openmeetings.web.app.WebSession) OmException(org.apache.openmeetings.util.OmException)

Example 7 with WebSession

use of org.apache.openmeetings.web.app.WebSession in project openmeetings by apache.

the class RoomResourceReference method getFileItem.

@Override
protected FileItem getFileItem(Attributes attr) {
    PageParameters params = attr.getParameters();
    StringValue _id = params.get("id");
    String uid = params.get("uid").toString();
    Long id = null;
    try {
        id = _id.toOptionalLong();
    } catch (NumberFormatException e) {
    // no-op expected
    }
    WebSession ws = WebSession.get();
    Client c = cm.get(uid);
    if (id == null || !ws.isSignedIn() || c == null) {
        return null;
    }
    FileItem f = (FileItem) fileDao.getAny(id);
    if (f == null) {
        return null;
    }
    String ruid = params.get("ruid").toString();
    String wuid = params.get("wuid").toString();
    if (c.getRoom() != null) {
        Whiteboards wbs = wbManager.get(c.getRoom().getId());
        if (!Strings.isEmpty(wuid) && !Strings.isEmpty(ruid) && ruid.equals(wbs.getUid())) {
            for (Entry<Long, Whiteboard> e : wbs.getWhiteboards().entrySet()) {
                JSONObject file = e.getValue().get(wuid);
                if (file != null && f.getId().equals(file.optLong(ATTR_FILE_ID))) {
                    // item IS on WB
                    return f;
                }
            }
        }
    }
    if (f.getGroupId() != null && groupUserDao.isUserInGroup(f.getGroupId(), getUserId())) {
        return f;
    }
    return null;
}
Also used : FileItem(org.apache.openmeetings.db.entity.file.FileItem) WebSession(org.apache.openmeetings.web.app.WebSession) Whiteboards(org.apache.openmeetings.db.dto.room.Whiteboards) JSONObject(com.github.openjson.JSONObject) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) StringValue(org.apache.wicket.util.string.StringValue) Client(org.apache.openmeetings.db.entity.basic.Client) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard)

Example 8 with WebSession

use of org.apache.openmeetings.web.app.WebSession in project openmeetings by apache.

the class TestUserService method hashTest.

@Test
public void hashTest() throws OmException {
    ServiceResult r = login();
    ServiceResult r1 = getHash(r.getMessage(), false);
    assertEquals("OM Call should be successful", Type.SUCCESS.name(), r1.getType());
    // to ensure WebSession is attached
    ensureApplication(-1L);
    WebSession ws = WebSession.get();
    assertTrue(ws.signIn(adminUsername, userpass, User.Type.user, null));
    Long userId0 = WebSession.getUserId();
    ws.checkHashes(StringValue.valueOf(r1.getMessage()), StringValue.valueOf(""));
    assertTrue("Login via secure hash should be successful", ws.isSignedIn());
    Long userId1 = WebSession.getUserId();
    Assert.assertNotEquals(userId0, userId1);
}
Also used : ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) WebSession(org.apache.openmeetings.web.app.WebSession) Test(org.junit.Test)

Example 9 with WebSession

use of org.apache.openmeetings.web.app.WebSession in project openmeetings by apache.

the class TestLoginUI method checkLogin.

private void checkLogin(String login, String pass) {
    FormTester formTester = tester.newFormTester("signin:signin");
    formTester.setValue("login", login);
    formTester.setValue("pass", pass);
    formTester.submit("submit");
    tester.assertNoErrorMessage();
    tester.assertRenderedPage(MainPage.class);
    WebSession ws = (WebSession) tester.getSession();
    assertTrue("Login should be successful", ws.isSignedIn());
}
Also used : WebSession(org.apache.openmeetings.web.app.WebSession) FormTester(org.apache.wicket.util.tester.FormTester)

Aggregations

WebSession (org.apache.openmeetings.web.app.WebSession)9 StringValue (org.apache.wicket.util.string.StringValue)4 Room (org.apache.openmeetings.db.entity.room.Room)3 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)3 OmException (org.apache.openmeetings.util.OmException)2 Test (org.junit.Test)2 JSONObject (com.github.openjson.JSONObject)1 JQueryBehavior (com.googlecode.wicket.jquery.core.JQueryBehavior)1 DialogButton (com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton)1 MessageDialog (com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog)1 IOException (java.io.IOException)1 FastDateFormat (org.apache.commons.lang3.time.FastDateFormat)1 ServiceResult (org.apache.openmeetings.db.dto.basic.ServiceResult)1 Whiteboard (org.apache.openmeetings.db.dto.room.Whiteboard)1 Whiteboards (org.apache.openmeetings.db.dto.room.Whiteboards)1 Client (org.apache.openmeetings.db.entity.basic.Client)1 IWsClient (org.apache.openmeetings.db.entity.basic.IWsClient)1 WsClient (org.apache.openmeetings.db.entity.basic.WsClient)1 Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)1 MeetingMember (org.apache.openmeetings.db.entity.calendar.MeetingMember)1