org.apache.wicket.authorization.UnauthorizedInstantiationException Java Examples

The following examples show how to use org.apache.wicket.authorization.UnauthorizedInstantiationException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestMainAreas.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
private void checkUnauthArea(AreaKeys area, String type, String... users) throws OmException {
	for (String user : users) {
		log.debug("Positive test:: area: {}, type: {} for user: {}", area, type, user);
		testArea(user, p -> {
			tester.getRequest().setParameter(area.name(), type);
			try {
				tester.executeBehavior((AbstractAjaxBehavior)p.getBehaviorById(0));
				fail("Not authorized");
			} catch (UnauthorizedInstantiationException e) {
				assertTrue(true, "Exception is expected");
			}
		});
	}
}
 
Example #2
Source File: TestSecurity.java    From wicket-orientdb with Apache License 2.0 5 votes vote down vote up
@Test(expected=UnauthorizedInstantiationException.class)
public void testStaticPageForSigned()
{
	WicketOrientDbTester tester = wicket.getTester();
	assertEquals(tester.getApplication().getOrientDbSettings().getGuestUserName(), tester.getDatabase().getUser().getName());
	assertTrue(tester.signIn("reader", "reader"));
	tester.startPage(StaticSecuredPage.class);
	tester.signOut();
}
 
Example #3
Source File: SyncopeUIRequestCycleListener.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Override
public IRequestHandler onException(final RequestCycle cycle, final Exception e) {
    LOG.error("Exception found", e);

    PageParameters errorParameters = new PageParameters();

    IRequestablePage errorPage;
    if (instanceOf(e, UnauthorizedInstantiationException.class) != null) {
        errorParameters.add("errorMessage", BaseSession.Error.AUTHORIZATION.fallback());
        errorPage = getErrorPage(errorParameters);
    } else if (instanceOf(e, AccessControlException.class) != null) {
        if (StringUtils.containsIgnoreCase(instanceOf(e, AccessControlException.class).getMessage(), "expired")) {
            errorParameters.add("errorMessage", BaseSession.Error.SESSION_EXPIRED.fallback());
        } else {
            errorParameters.add("errorMessage", BaseSession.Error.AUTHORIZATION.fallback());
        }
        errorPage = getErrorPage(errorParameters);
    } else if (instanceOf(e, PageExpiredException.class) != null || !isSignedIn()) {
        errorParameters.add("errorMessage", BaseSession.Error.SESSION_EXPIRED.fallback());
        errorPage = getErrorPage(errorParameters);
    } else if (instanceOf(e, BadRequestException.class) != null
            || instanceOf(e, WebServiceException.class) != null
            || instanceOf(e, SyncopeClientException.class) != null) {

        errorParameters.add("errorMessage", BaseSession.Error.REST.fallback());
        errorPage = getErrorPage(errorParameters);
    } else {
        Throwable cause = instanceOf(e, ForbiddenException.class);
        if (cause == null) {
            // redirect to default Wicket error page
            errorPage = new ExceptionErrorPage(e, null);
        } else {
            errorParameters.add("errorMessage", cause.getMessage());
            errorPage = getErrorPage(errorParameters);
        }
    }

    if (errorPage instanceof BaseLogin) {
        try {
            invalidateSession();
        } catch (Throwable t) {
            // ignore
            LOG.debug("Unexpected error while forcing logout after error", t);
        }
    }

    return new RenderPageRequestHandler(new PageProvider(errorPage));
}