Example usage for org.apache.wicket RestartResponseAtInterceptPageException RestartResponseAtInterceptPageException

List of usage examples for org.apache.wicket RestartResponseAtInterceptPageException RestartResponseAtInterceptPageException

Introduction

In this page you can find the example usage for org.apache.wicket RestartResponseAtInterceptPageException RestartResponseAtInterceptPageException.

Prototype

public RestartResponseAtInterceptPageException(Class<? extends Page> interceptPageClass) 

Source Link

Document

Redirects to the specified intercept page, this will result in a bookmarkable redirect.

Usage

From source file:au.org.theark.security.CustomUnauthorizedStrategy.java

License:Open Source License

public void onUnauthorizedInstantiation(Component component) {

    System.out.println("Unauthorized Instantiation");
    if (component instanceof Page) {
        System.out.println("\nComponent is instance of Page " + component.getClass().getName());
        throw new RestartResponseAtInterceptPageException(LoginPage.class);
    } else {/*  w  w  w.ja v a 2  s . c o m*/
        System.out.println("\n SetVisible False for component " + component.getClass().getName());
        component.setVisible(false);
    }

}

From source file:br.com.ieptbto.cra.security.UserRoleAuthorizationStrategy.java

License:Open Source License

@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) {
    for (IAuthorizationStrategy strategy : strategies) {
        if (strategy.isInstantiationAuthorized(componentClass) == false) {
            ISecureApplication app = (ISecureApplication) Application.get();
            throw new RestartResponseAtInterceptPageException(app.getLoginPage());
        }/*from  www  .  ja v a2  s.c  o  m*/
    }
    return true;
}

From source file:com.ccc.crest.servlet.auth.CrestAuthCallback.java

License:Open Source License

@Override
protected void handleCallback(PageParameters parameters, SessionClientInfo sessionClientInfo) throws Exception {
    super.handleCallback(parameters, sessionClientInfo);
    try {//from www .jav  a 2 s .co  m
        CrestClientInfo clientInfo = (CrestClientInfo) sessionClientInfo.getOauthClientInfo();
        getVerifyData(clientInfo);
        CoreController.getController().fireAuthenticatedEvent(clientInfo, AuthEventListener.Type.Authenticated);
    } catch (Exception e) {
        LoggerFactory.getLogger(getClass()).info("OAuth authentication phase 2 failed", e);
        throw new RestartResponseAtInterceptPageException(SignOutPage.class);
    }
    throw new RestartResponseAtInterceptPageException(LoginPage.class);
}

From source file:com.ccc.crest.servlet.CrestServlet.java

License:Open Source License

@Override
public void needsApiKey(CrestClientInfo clientInfo) {
    throw new RestartResponseAtInterceptPageException(SignOutPage.class);

}

From source file:com.example.justaddwater.web.app.ChangePasswordPage.java

License:Apache License

public ChangePasswordPage(final PageParameters parameters) {
    super(parameters);

    add(new Header("header"));

    enclosingDiv = new WebMarkupContainer("enclosing-div");
    enclosingDiv.setOutputMarkupId(true);

    if (!session.isLoggedIn()) {
        error("not logged in");
        throw new RestartResponseAtInterceptPageException(LoginPage.class);
    }/*w w  w .  java 2 s  .  c o m*/

    Form form = new Form("form");
    form.setOutputMarkupId(true);

    feedback = new FeedbackPanel("feedback");
    feedback.setOutputMarkupId(true);
    form.add(feedback);

    currentPasswordField = new PasswordTextField("current-password", new Model<String>());
    currentPasswordField.setRequired(true);

    passwordField = new PasswordTextField("password", new Model<String>());
    passwordField.setRequired(true);
    passwordField.add(StringValidator.lengthBetween(6, 32));

    PasswordTextField confirmPasswordField = new PasswordTextField("confirm-password", new Model<String>());
    confirmPasswordField.setRequired(true);

    form.add(currentPasswordField);
    form.add(passwordField);
    form.add(confirmPasswordField);

    form.add(new EqualPasswordInputValidator(passwordField, confirmPasswordField));

    AjaxButton submit = new AjaxButton("submit") {
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            String currentPassword = currentPasswordField.getModelObject();
            String newPassword = passwordField.getModelObject();
            User user = dao.findUserByEmail(session.getUsername());

            if (user == null) {
                error("not logged in");
                throw new RestartResponseAtInterceptPageException(LoginPage.class);
            } else if (currentPasswordIsValid(user, currentPassword)) {

                changePassword(user, newPassword);
                EntityManager em = emModel.getObject();
                em.persist(user);
                action.apply(em); // save changes
                successMessage.setVisible(true);
                form.setVisible(false);
            } else {
                error("current password is invalid");
            }

            target.add(enclosingDiv);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(feedback);
            target.add(enclosingDiv);
        }
    };

    form.add(submit);
    enclosingDiv.add(form);

    successMessage = new WebMarkupContainer("success-message");
    successMessage.setOutputMarkupId(true);
    successMessage.setVisible(false);
    enclosingDiv.add(successMessage);

    add(enclosingDiv);

}

From source file:com.example.justaddwater.web.app.RecoverPasswordPage.java

License:Apache License

public RecoverPasswordPage(final PageParameters parameters) {
    super(parameters);
    add(new Header("header"));

    String token = parameters.get("token").toString();
    OneTimeLogin otl = dao.findOneTimeLoginByToken(token);
    if (otl == null) {
        error("login token invalid");
        throw new RestartResponseAtInterceptPageException(ForgotPasswordPage.class);
    } else if (otl.isExpired()) {
        error("login token expired");
        throw new RestartResponseAtInterceptPageException(ForgotPasswordPage.class);
    } else {// w w w.  j  a v a2s . c om
        loginViaOneTimePassword(otl);
    }

    enclosure = new WebMarkupContainer("enclosure");
    enclosure.setOutputMarkupId(true);

    Form form = new Form("form") {
        @Override
        protected void onSubmit() {
            User user = session.getLoggedInUser();
            changePassword(user, passwordField.getModelObject());
            enclosure.setVisible(false);
            successMessage.setVisible(true);
        }
    };

    FeedbackPanel feedback = new FeedbackPanel("feedback");
    feedback.setOutputMarkupId(true);
    form.add(feedback);

    passwordField = new PasswordTextField("password", new Model<String>());
    passwordField.setRequired(true);
    passwordField.add(StringValidator.lengthBetween(6, 32));

    PasswordTextField confirmPasswordField = new PasswordTextField("confirmPassword", new Model<String>());
    confirmPasswordField.setRequired(true);

    form.add(passwordField);
    form.add(confirmPasswordField);
    form.add(new EqualPasswordInputValidator(passwordField, confirmPasswordField));

    successMessage = new WebMarkupContainer("successMessage");
    successMessage.setOutputMarkupId(true);
    successMessage.setVisible(false);
    add(successMessage);

    enclosure.add(form);
    add(enclosure);
}

From source file:com.genericconf.bbbgateway.web.pages.ManageMeeting.java

License:Apache License

public ManageMeeting(PageParameters params) {
    final String meetingID = params.getString("0");
    String check = params.getString("1");
    boolean okay = createCheck(meetingID).equals(check);
    logger.info("meeting ID: " + meetingID + "; check: " + check + "; okay: " + okay);
    if (!okay) {/*from w  w  w .  j  ava 2s . c  o  m*/
        getSession().error("You are not authorized to manage that meeting");
        throw new RestartResponseAtInterceptPageException(getApplication().getHomePage());
    }
    IModel<Meeting> model = new LoadableDetachableModel<Meeting>() {
        private static final long serialVersionUID = 1L;

        @Override
        protected Meeting load() {
            final Meeting mtg = meetingService.findByMeetingID(meetingID);
            if (mtg == null) {
                getSession().error("That meeting no longer exists");
                throw new RestartResponseAtInterceptPageException(getApplication().getHomePage());
            }
            return mtg;
        }
    };
    setDefaultModel(new CompoundPropertyModel<Meeting>(model));

    add(new Label("name"));
    add(new Label("meetingID"));
    add(new Label("attendeePassword"));
    add(new Label("moderatorPassword"));
    add(maxAtts = new Label("maximumAttendees"));
    maxAtts.setOutputMarkupId(true);
    attendeeList = new AttendeeAndWaitingListPanel("attendeeList", getModel());
    add(attendeeList.setAllowAdminControls(true));

    checked = new DateTimeLabel("checkedTime", new AlwaysReturnCurrentDateModel());
    add(checked.setOutputMarkupId(true));

    final Form<Void> bulkAllowForm = new Form<Void>("bulkAllowForm");
    add(bulkAllowForm.setOutputMarkupId(true));
    final Model<Integer> howMany = new Model<Integer>(0);
    bulkAllowForm.add(new TextField<Integer>("howMany", howMany, Integer.class));
    bulkAllowForm.add(new AjaxButton("submit") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            if (howMany.getObject() <= 0) {
                target.appendJavascript("alert('must be a positive number');");
            } else {
                final Meeting meeting = ManageMeeting.this.getModel().getObject();
                meeting.increaseMaximumAttendees(howMany.getObject());
                meetingService.bulkAllowAttendees(meeting);
                ManageMeeting.this.onPageAjaxRequest(target);
            }
        }
    });

    add(new AbstractAjaxTimerBehavior(
            Duration.seconds(TimerSettings.INSTANCE.getSecondsBetweenManageMeetingPagePolls())) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onTimer(AjaxRequestTarget target) {
            ManageMeeting.this.onPageAjaxRequest(target);
        }
    });
}

From source file:com.genericconf.bbbgateway.web.pages.WaitingRoom.java

License:Apache License

public WaitingRoom(PageParameters params) {
    final String meetingID = params.getString("0");
    final String attName = params.getString("1");
    if (StringUtils.isEmpty(meetingID) || StringUtils.isEmpty(attName)) {
        throw new RestartResponseAtInterceptPageException(getApplication().getHomePage());
    }//w  ww  .j  a  va  2 s .  c o  m
    meeting = new LoadableDetachableModel<Meeting>() {
        private static final long serialVersionUID = 1L;

        @Override
        protected Meeting load() {
            return meetingService.findByMeetingID(meetingID);
        }
    };
    attendee = new LoadableDetachableModel<Attendee>() {
        private static final long serialVersionUID = 1L;

        @Override
        protected Attendee load() {
            return meeting.getObject().getAttendeeByName(attName);
        }
    };

    add(new Label("name", new PropertyModel<String>(meeting, "name")));
    add(new Label("meetingID", new PropertyModel<String>(meeting, "meetingID")));

    add(new Label("attName", new PropertyModel<String>(attendee, "name")));
    add(new Label("attRole", new PropertyModel<String>(attendee, "role")));

    final AttendeeAndWaitingListPanel attendeeList = new AttendeeAndWaitingListPanel("attendeeList", meeting);
    add(attendeeList);

    final DateTimeLabel checked = new DateTimeLabel("checkedTime", new AlwaysReturnCurrentDateModel());
    add(checked.setOutputMarkupId(true));

    final WebMarkupContainer joinDialog = new WebMarkupContainer("joinDialog");
    add(joinDialog.setOutputMarkupId(true));

    add(new AbstractAjaxTimerBehavior(
            Duration.seconds(TimerSettings.INSTANCE.getSecondsBeforeFirstWaitingRoomPagePoll())) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onTimer(AjaxRequestTarget target) {
            target.addComponent(checked);
            setUpdateInterval(Duration.seconds(TimerSettings.INSTANCE.getSecondsBetweenWaitingRoomPagePolls()));
            attendeeList.onAjaxRequest(target);
            final Attendee att = attendee.getObject();
            att.pinged();
            if (att.isAllowedToJoin()) {
                stop();

                final JoinMeetingLinkPanel panel = new JoinMeetingLinkPanel(joinDialog.getId(), meeting,
                        attendee);
                joinDialog.replaceWith(panel);
                target.addComponent(panel);

                StringBuffer js = new StringBuffer().append("$('#").append(panel.getMarkupId())
                        .append("').dialog({ modal: true, title: 'Join Meeting' });");
                target.appendJavascript(js.toString());
            }
        }
    });
}

From source file:com.genericconf.bbbgateway.web.panels.JoinMeetingLinkPanel.java

License:Apache License

public JoinMeetingLinkPanel(String id, final IModel<Meeting> meeting, final IModel<Attendee> attendee) {
    super(id);/*w w  w . j  a v  a2  s. c  o  m*/
    setOutputMarkupId(true);

    add(new Link<Void>("join") {
        private static final long serialVersionUID = 1L;

        @SpringBean
        private IMeetingService meetingService;

        @Override
        public void onClick() {
            String url = meetingService.joinMeeting(meeting.getObject(), attendee.getObject());
            throw new RestartResponseAtInterceptPageException(new RedirectPage(url));
        }

    });
}

From source file:com.googlecode.wicketelements.security.UnauthorizedComponentInstantiationListener.java

License:Apache License

public void onUnauthorizedInstantiation(final Component componentParam) {
    PARAM_REQ.Object.requireNotNull(componentParam, "The component parameter must not be null.");
    if (!SecureSession.get().isAuthenticated()) {
        LOGGER.debug("Unauthorized and user not authenticated.");
        if (securityCheck.isApplicationWithSignInPageSpecified()) {
            LOGGER.debug("Application has a sign in page specified. Setting sign in page as response.");
            throw new RestartResponseAtInterceptPageException(securityCheck.signInPage());
        }/*from  w w w  .  ja v a  2s  . c  o  m*/
    }
    LOGGER.debug("Setting access denied page as response.");
    throw new RestartResponseException(WebApplication.get().getApplicationSettings().getAccessDeniedPage());
}