Search in sources :

Example 1 with WebSession

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

the class GroupLogoResourceReference method getResource.

@Override
public IResource getResource() {
    return new FileSystemResource() {

        private static final long serialVersionUID = 1L;

        @Override
        protected String getMimeType() throws IOException {
            return PNG_MIME_TYPE;
        }

        @Override
        protected ResourceResponse newResourceResponse(Attributes attrs) {
            Long id = null;
            boolean allowed = false;
            WebSession ws = WebSession.get();
            if (ws.isSignedIn()) {
                PageParameters params = attrs.getParameters();
                StringValue _id = params.get("id");
                try {
                    id = _id.toOptionalLong();
                } catch (Exception e) {
                // no-op expected
                }
                allowed = id == null || hasAdminLevel(getRights()) || null != groupUserDao.getByGroupAndUser(id, getUserId());
                if (!allowed && ws.getInvitation() != null) {
                    Room r = ws.getInvitation().getRoom() == null ? null : roomDao.get(ws.getInvitation().getRoom().getId());
                    if (r != null && r.getGroups() != null) {
                        for (RoomGroup rg : r.getGroups()) {
                            if (id.equals(rg.getGroup().getId())) {
                                allowed = true;
                                break;
                            }
                        }
                    }
                }
            }
            if (allowed) {
                return createResourceResponse(attrs, getGroupLogo(id, true).toPath());
            } else {
                log.debug("Not authorized");
                ResourceResponse rr = new ResourceResponse();
                rr.setError(HttpServletResponse.SC_FORBIDDEN);
                return rr;
            }
        }
    };
}
Also used : WebSession(org.apache.openmeetings.web.app.WebSession) FileSystemResource(org.apache.wicket.resource.FileSystemResource) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) RoomGroup(org.apache.openmeetings.db.entity.room.RoomGroup) StringValue(org.apache.wicket.util.string.StringValue) Room(org.apache.openmeetings.db.entity.room.Room) IOException(java.io.IOException)

Example 2 with WebSession

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

the class HashPage method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    StringValue secure = p.get(HASH);
    StringValue invitation = p.get(INVITATION_HASH);
    WebSession ws = WebSession.get();
    ws.checkHashes(secure, invitation);
    String errorMsg = getString("invalid.hash");
    recContainer.setVisible(false);
    add(new EmptyPanel(PANEL_MAIN).setVisible(false));
    if (!invitation.isEmpty()) {
        Invitation i = ws.getInvitation();
        if (i == null) {
            errorMsg = getString("error.hash.invalid");
        } else if (!i.isAllowEntry()) {
            FastDateFormat sdf = FormatHelper.getDateTimeFormat(i.getInvitee());
            errorMsg = Valid.OneTime == i.getValid() ? getString("error.hash.used") : String.format("%s %s - %s, %s", getString("error.hash.period"), sdf.format(i.getValidFrom()), sdf.format(i.getValidTo()), i.getInvitee().getTimeZoneId());
        } else {
            Recording rec = i.getRecording();
            if (rec != null) {
                vi.setVisible(!i.isPasswordProtected());
                vp.setVisible(!i.isPasswordProtected());
                if (!i.isPasswordProtected()) {
                    vi.update(null, rec);
                    vp.update(null, rec);
                }
                recContainer.setVisible(true);
                error = false;
            }
            Room r = i.getRoom();
            if (r != null && !r.isDeleted()) {
                createRoom(r.getId());
                if (i.isPasswordProtected() && rp != null) {
                    mp.getChat().setVisible(false);
                    rp.setOutputMarkupPlaceholderTag(true).setVisible(false);
                }
            }
        }
    } else if (!secure.isEmpty()) {
        Long recId = getRecordingId(), roomId = ws.getRoomId();
        if (recId == null && roomId == null) {
            errorMsg = getString("1599");
        } else if (recId != null) {
            recContainer.setVisible(true);
            Recording rec = recDao.get(recId);
            vi.update(null, rec);
            vp.update(null, rec);
            error = false;
        } else {
            createRoom(roomId);
        }
    }
    StringValue swf = p.get(SWF);
    StringValue app = swf.isEmpty() ? p.get(APP) : swf;
    if (!app.isEmpty()) {
        if (APP_TYPE_NETWORK.equals(app.toString())) {
            replace(new NetTestPanel(PANEL_MAIN).add(AttributeModifier.append("class", "app")));
            error = false;
        }
        if (APP_TYPE_SETTINGS.equals(app.toString())) {
            replace(new VideoSettings(PANEL_MAIN).replace(new OmWebSocketPanel("ws-panel") {

                private static final long serialVersionUID = 1L;

                private WsClient c = null;

                @Override
                protected void onConnect(ConnectedMessage message) {
                    c = new WsClient(message.getSessionId(), message.getKey().hashCode());
                }

                @Override
                protected IWsClient getWsClient() {
                    return c;
                }
            }).add(new OmAjaxClientInfoBehavior() {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onClientInfo(AjaxRequestTarget target, WebClientInfo info) {
                    super.onClientInfo(target, info);
                    target.appendJavaScript(String.format("VideoSettings.init(%s);VideoSettings.open();", VideoSettings.getInitJson("noclient")));
                }
            }));
            error = false;
        }
    }
    add(recContainer.add(vi.setShowShare(false).setOutputMarkupPlaceholderTag(true), vp.setOutputMarkupPlaceholderTag(true)), new InvitationPasswordDialog("i-pass", this));
    remove(urlParametersReceivingBehavior);
    add(new MessageDialog("access-denied", getString("invalid.hash"), errorMsg, DialogButtons.OK, DialogIcon.ERROR) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onConfigure(JQueryBehavior behavior) {
            super.onConfigure(behavior);
            behavior.setOption("autoOpen", error);
            behavior.setOption("resizable", false);
        }

        @Override
        public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
        // no-op
        }
    });
}
Also used : WebClientInfo(org.apache.wicket.protocol.http.request.WebClientInfo) DialogButton(com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton) EmptyPanel(org.apache.wicket.markup.html.panel.EmptyPanel) OmWebSocketPanel(org.apache.openmeetings.web.common.OmWebSocketPanel) WsClient(org.apache.openmeetings.db.entity.basic.WsClient) IWsClient(org.apache.openmeetings.db.entity.basic.IWsClient) ConnectedMessage(org.apache.wicket.protocol.ws.api.message.ConnectedMessage) MessageDialog(com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog) StringValue(org.apache.wicket.util.string.StringValue) Room(org.apache.openmeetings.db.entity.room.Room) IWsClient(org.apache.openmeetings.db.entity.basic.IWsClient) JQueryBehavior(com.googlecode.wicket.jquery.core.JQueryBehavior) VideoSettings(org.apache.openmeetings.web.room.VideoSettings) Invitation(org.apache.openmeetings.db.entity.room.Invitation) OmAjaxClientInfoBehavior(org.apache.openmeetings.web.common.OmAjaxClientInfoBehavior) IPartialPageRequestHandler(org.apache.wicket.core.request.handler.IPartialPageRequestHandler) FastDateFormat(org.apache.commons.lang3.time.FastDateFormat) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) WebSession(org.apache.openmeetings.web.app.WebSession) NetTestPanel(org.apache.openmeetings.web.room.NetTestPanel) Recording(org.apache.openmeetings.db.entity.record.Recording)

Example 3 with WebSession

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

the class SignInDialog method onSubmit.

@Override
protected void onSubmit(AjaxRequestTarget target) {
    if (domain.getAddDomainToUserName()) {
        login = login + "@" + domain.getDomain();
    }
    OmAuthenticationStrategy strategy = getAuthenticationStrategy();
    WebSession ws = WebSession.get();
    Type type = domain.getId() > 0 ? Type.ldap : Type.user;
    boolean signIn = false;
    try {
        signIn = ws.signIn(login, password, type, domain.getId());
    } catch (OmException e) {
        error(getString(e.getKey()));
        target.add(feedback);
    }
    if (signIn) {
        setResponsePage(Application.get().getHomePage());
        if (rememberMe) {
            strategy.save(login, password, type, domain.getId());
        } else {
            strategy.remove();
        }
    } else {
        if (!hasErrorMessage()) {
            error(getString("error.bad.credentials"));
            target.add(feedback);
        }
        // add random timeout
        try {
            Thread.sleep(6 + (long) (10 * Math.random() * 1000));
        } catch (InterruptedException e) {
            log.error("Unexpected exception while sleeping", e);
        }
        strategy.remove();
        shake(target);
    }
}
Also used : Type(org.apache.openmeetings.db.entity.user.User.Type) WebSession(org.apache.openmeetings.web.app.WebSession) OmException(org.apache.openmeetings.util.OmException) OmAuthenticationStrategy(org.apache.openmeetings.web.app.OmAuthenticationStrategy)

Example 4 with WebSession

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

the class TestAppointmentAddAppointment method testCreate.

@Test
public void testCreate() {
    Appointment a = new Appointment();
    a.setTitle("Test title");
    setTime(a);
    a.setReminder(Reminder.ical);
    a.setMeetingMembers(new ArrayList<>());
    User owner = userDao.get(1L);
    a.setOwner(owner);
    a.setRoom(new Room());
    a.getRoom().setAppointment(true);
    a.getRoom().setType(Room.Type.conference);
    for (int i = 0; i < 3; ++i) {
        MeetingMember mm = new MeetingMember();
        mm.setUser(getContact(UUID.randomUUID().toString(), owner.getId()));
        a.getMeetingMembers().add(mm);
    }
    a = appointmentDao.update(a, owner.getId());
    assertNotNull("Saved appointment should have valid id: " + a.getId(), a.getId());
    assertEquals("Saved appointment should have corect count of guests: ", 3, a.getMeetingMembers().size());
    for (MeetingMember mm : a.getMeetingMembers()) {
        assertNotNull("Saved guest should have valid id: ", mm.getId());
        assertNotNull("Saved guest should have valid invitation: ", mm.getInvitation());
        assertNotNull("Saved guest should have invitation with ID: ", mm.getInvitation().getId());
    }
    WebSession ws = WebSession.get();
    Appointment a1 = appointmentDao.get(a.getId());
    ws.checkHashes(StringValue.valueOf(""), StringValue.valueOf(a1.getMeetingMembers().get(0).getInvitation().getHash()));
    assertTrue("Login via secure hash should be successful", ws.isSignedIn());
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) User(org.apache.openmeetings.db.entity.user.User) WebSession(org.apache.openmeetings.web.app.WebSession) MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember) Room(org.apache.openmeetings.db.entity.room.Room) Test(org.junit.Test)

Example 5 with WebSession

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

the class RecordingResourceReference method getFileItem.

@Override
protected Recording getFileItem(Attributes attributes) {
    PageParameters params = attributes.getParameters();
    StringValue _id = params.get("id");
    String ruid = params.get("ruid").toString();
    String uid = params.get("uid").toString();
    Long id = null;
    try {
        id = _id.toOptionalLong();
    } catch (Exception e) {
    // no-op expected
    }
    WebSession ws = WebSession.get();
    if (id == null && ws.signIn(_id.toString(), true)) {
        id = getRecordingId();
    }
    if (id != null && ws.isSignedIn()) {
        return getRecording(id, ruid, uid);
    }
    return null;
}
Also used : WebSession(org.apache.openmeetings.web.app.WebSession) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) StringValue(org.apache.wicket.util.string.StringValue)

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