org.apache.wicket.protocol.http.WebApplication Java Examples

The following examples show how to use org.apache.wicket.protocol.http.WebApplication. 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: ShiroSecurityConfig.java    From wicket-spring-boot with Apache License 2.0 6 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	AnnotationsShiroAuthorizationStrategy authz = new AnnotationsShiroAuthorizationStrategy();
	webApplication.getSecuritySettings().setAuthorizationStrategy( authz );

	if ( classCandidates.getSignInPageCandidates().size() <= 0 ) {
		throw new IllegalStateException( "Couln't find sign in page - please annotate the sign in page with @" + WicketSignInPage.class.getName() );
	}
	if ( classCandidates.getAccessDeniedPageCandidates().size() <= 0 ) {
		throw new IllegalStateException( "Couln't find access denied in page - please annotate the sign in page with @" + WicketAccessDeniedPage.class.getName() );
	}
	Class<WebPage> signInPage = classCandidates.getSignInPageCandidates().iterator().next().getCandidate();
	Class<Page> accessDeniedPage = classCandidates.getAccessDeniedPageCandidates().iterator().next().getCandidate();
	webApplication.getSecuritySettings()
			.setUnauthorizedComponentInstantiationListener( new ShiroUnauthorizedComponentListener( signInPage, accessDeniedPage, authz ) );

}
 
Example #2
Source File: StoreSettingsConfig.java    From wicket-spring-boot with Apache License 2.0 6 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	StoreSettings storeSettings = webApplication.getStoreSettings();
	if (props.getAsynchronous() != null) {
		storeSettings.setAsynchronous(props.getAsynchronous());
	}
	if (props.getAsynchronousQueueCapacity() != null) {
		storeSettings.setAsynchronousQueueCapacity(props.getAsynchronousQueueCapacity());
	}
	if (props.getFileStoreFolder() != null) {
		storeSettings.setFileStoreFolder(new File(props.getFileStoreFolder()));
	}
	if (props.getInmemoryCacheSize() != null) {
		storeSettings.setInmemoryCacheSize(props.getInmemoryCacheSize());
	}
	storeSettings.setMaxSizePerSession(TypeParser.parse(props.getSessionSize(), props.getSessionUnit()));
	
	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", props)
			.build());
}
 
Example #3
Source File: OrienteerTestModule.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
	
	bind(Boolean.class).annotatedWith(Names.named("testing")).toInstance(true);
	bindListener(InstanceOfMatcher.createFor(WebApplication.class), new TypeListener() {
		
		@Override
		public <I> void hear(TypeLiteral<I> type, final TypeEncounter<I> encounter) {
			final Provider<Injector> injectorProvider = encounter.getProvider(Injector.class);
			encounter.register((InjectionListener<Object>) injected -> {
                   WebApplication app = (WebApplication) injected;
                   app.getComponentInstantiationListeners().add(new GuiceComponentInjector(app, injectorProvider.get()));
               });
		}
	});
	bind(OrienteerTester.class).asEagerSingleton();
	Provider<OrienteerTester> provider = binder().getProvider(OrienteerTester.class);
	bind(WicketTester.class).toProvider(provider);
	bind(WicketOrientDbTester.class).toProvider(provider);
}
 
Example #4
Source File: DataStoreRedisConfig.java    From wicket-spring-boot with Apache License 2.0 6 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	
	webApplication.setPageManagerProvider(new DefaultPageManagerProvider(webApplication) {
		protected IDataStore newDataStore() {
			IRedisSettings settings = new RedisSettings();
			settings.setHostname(prop.getHostname());
			settings.setPort(prop.getPort());
			settings.setRecordTtl(TypeParser.parse(prop.getRecordTtl(), prop.getRecordTtlUnit()));
			
			RedisDataStore redisDataStore = new RedisDataStore(settings );
			return new SessionQuotaManagingDataStore(redisDataStore, TypeParser.parse(prop.getSessionSize(), prop.getSessionUnit()));
		}
	});

	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", prop)
			.build());
	
}
 
Example #5
Source File: CsrfAttacksPreventionConfig.java    From wicket-spring-boot with Apache License 2.0 6 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	CsrfPreventionRequestCycleListener listener = new CsrfPreventionRequestCycleListener();
	listener.setConflictingOriginAction(props.getConflictingOriginAction());
	listener.setErrorCode(props.getErrorCode());
	listener.setErrorMessage(props.getErrorMessage());
	listener.setNoOriginAction(props.getNoOriginAction());
	for (String acceptedOrigin : props.getAcceptedOrigins()) {
		listener.addAcceptedOrigin(acceptedOrigin);
	}
	webApplication.getRequestCycleListeners().add(listener);
	
	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", props)
			.build());
}
 
Example #6
Source File: ApplicationHelper.java    From openmeetings with Apache License 2.0 6 votes vote down vote up
public static IApplication ensureApplication() {
	if (Application.exists()) {
		return (IApplication)Application.get();
	}
	synchronized (SYNC_OBJ) {
		if (Application.exists()) {
			return (IApplication)Application.get();
		}
		WebApplication app = createApp((WebApplication)Application.get(getWicketApplicationName()));
		LabelDao.initLanguageMap();
		if (app != null) {
			if (!isInitComplete()) {
				initApp(app);
			}
			ThreadContext.setApplication(app);
		}
		return (IApplication)Application.get(getWicketApplicationName());
	}
}
 
Example #7
Source File: BootstrapPaginatorTest.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 6 votes vote down vote up
private WicketTester createTester(){
	WicketTester tester = new WicketTester(new WebApplication() {
		
		@Override
		public Class<? extends Page> getHomePage() {
			return null;
		}
	}){
		@Override
		protected String createPageMarkup(String componentId) {
			return "<div class=\"pagination pagination-small pagination-right\" wicket:id=\"paginator\">"+
					"</div>";
		}
	};
	
	return tester;
}
 
Example #8
Source File: UrlImporter.java    From webanno with Apache License 2.0 6 votes vote down vote up
private Optional<Import> resolveWebContextDependency(String url)
{
    LOG.debug("Going to resolve an import from the web context: {}", url);
    String resourceName = url.substring(WEB_CONTEXT_SCHEME.length());
    if (resourceName.indexOf(0) == '/') {
        resourceName = resourceName.substring(1);
    }

    final ServletContext context = ((WebApplication) Application.get()).getServletContext();
    try {
        return Optional.of(buildImport(context.getResource(resourceName)));
    }
    catch (MalformedURLException ex) {
        throw new IllegalArgumentException(
                "Cannot create a URL to a resource in the web context", ex);
    }
}
 
Example #9
Source File: WicketResourceMounterImpl.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void mountResources(final WebApplication webApplication) {

    if (resources != null) {
        for (final Map.Entry<String, IResource> resource : resources.entrySet()) {
            final String key = resource.getKey();
            final IResource source = resource.getValue();
            LOG.info("Mounting url '/{}' to resource '{}'", key, source.getClass().getCanonicalName());
            webApplication.mountResource("/" + key, new ResourceReference(key){
                @Override
                public IResource getResource() {
                    return source;
                }
            });
        }
    }

}
 
Example #10
Source File: WicketResourceMounterImpl.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void enableResourceAccess(final WebApplication webApplication) {

    IPackageResourceGuard packageResourceGuard = webApplication.getResourceSettings().getPackageResourceGuard();
    if (packageResourceGuard instanceof SecurePackageResourceGuard)
    {
        SecurePackageResourceGuard guard = (SecurePackageResourceGuard) packageResourceGuard;

        if (enabledPatterns != null) {
            for (final String pattern : enabledPatterns) {
                LOG.info("Enabling resource pattern '{}'", pattern);
                guard.addPattern(pattern);
            }
        }
    }

}
 
Example #11
Source File: AbstractComponentTest.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Creates an instance of a Wicket {@link WebApplication} in which to run the tests. Can be overriden if specific functionality is
 * needed in the app, such as a specific home page. Note that this method is only called once, in the test constructor.
 * 
 * @return An instance of a {@link WebApplication}.
 */
protected WebApplication createApp() {
	return new WebApplication() {
		@Override
		public Class<? extends Page> getHomePage() {
			return null;
		}
	};
}
 
Example #12
Source File: WicketUtilsTest.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void isParent()
{
  new WicketTester(new WebApplication() {
    @Override
    public Class< ? extends Page> getHomePage()
    {
      return null;
    }
  });
  final WebMarkupContainer c1 = new WebMarkupContainer("c1");
  final WebMarkupContainer c2 = new WebMarkupContainer("c2");
  c1.add(c2);
  final WebMarkupContainer c3 = new WebMarkupContainer("c3");
  c2.add(c3);
  final Label l1 = new Label("l1", "l1");
  c3.add(l1);
  final Label l2 = new Label("l2", "l2");
  c1.add(l2);
  final Label l3 = new Label("l3", "l3");
  assertFalse(WicketUtils.isParent(c1, c1));
  assertTrue(WicketUtils.isParent(c1, c2));
  assertFalse(WicketUtils.isParent(c2, c1));
  assertTrue(WicketUtils.isParent(c1, c3));
  assertTrue(WicketUtils.isParent(c1, l1));
  assertTrue(WicketUtils.isParent(c2, l1));
  assertTrue(WicketUtils.isParent(c3, l1));
  assertTrue(WicketUtils.isParent(c1, l2));
  assertFalse(WicketUtils.isParent(c2, l2));
  assertFalse(WicketUtils.isParent(c1, l3));
}
 
Example #13
Source File: ExceptionSettingsConfig.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	ExceptionSettings exceptionSettings = webApplication.getExceptionSettings();
	
	exceptionSettings.setAjaxErrorHandlingStrategy(props.getErrorHandlingStrategyDuringAjaxRequests());
	exceptionSettings.setThreadDumpStrategy(props.getThreadDumpStrategy());
	
	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", props)
			.build());
}
 
Example #14
Source File: DebugSettingsConfig.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	if(properties.isEnabled()){
		DebugSettings debugSettings = webApplication.getDebugSettings();
		debugSettings.setDevelopmentUtilitiesEnabled(properties.isDevelopmentUtilitiesEnabled());
		debugSettings.setAjaxDebugModeEnabled(properties.isAjaxDebugModeEnabled());
		debugSettings.setComponentUseCheck(properties.isComponentUseCheck());
		debugSettings.setOutputMarkupContainerClassName(properties.isOutputMarkupContainerClassName());
		debugSettings.setComponentPathAttributeName(properties.getComponentPathAttributeName());
	}
	
	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", properties)
			.build());
}
 
Example #15
Source File: DeflatedJavaSerializerConfig.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	ISerializer currentSerializer = webApplication.getFrameworkSettings().getSerializer();
	if (currentSerializer instanceof JavaSerializer) {
		webApplication.getFrameworkSettings().setSerializer(new DeflatedJavaSerializer(webApplication.getApplicationKey()));
	} else {
		throw new ExtensionMisconfigurationException("DeflatedJavaSerializer: There is already another serializer configured " + currentSerializer);
	}
	
	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", props)
			.build());
}
 
Example #16
Source File: CryptMapperConfig.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	webApplication.setRootRequestMapper(new CryptoMapper(webApplication.getRootRequestMapper(), webApplication));
	
	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", props)
			.build());
}
 
Example #17
Source File: WebjarsConfig.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	WebjarsSettings settings = new WebjarsSettings();
       WicketWebjars.install(webApplication, settings);
       
       wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", props)
			.build());
       
}
 
Example #18
Source File: InspectorConfig.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	if (properties.isEnableLiveSessionsPage()) {
		webApplication.mountPage(properties.getLiveSessionPageMount(), LiveSessionsPage.class);
	}
	
	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", properties)
			.build());
}
 
Example #19
Source File: DataStoreMemcachedConfig.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	
	webApplication.setPageManagerProvider(new DefaultPageManagerProvider(webApplication) {
		protected IDataStore newDataStore() {
			IMemcachedSettings settings = new MemcachedSettings();
			settings.setExpirationTime(prop.getExpirationTime());
			settings.setPort(prop.getPort());
			settings.setServerNames(prop.getServerNames());
			settings.setShutdownTimeout(TypeParser.parse(prop.getShutdownTimeout(), prop.getShutdownTimeoutUnit()));
			MemcachedDataStore memcachedDataStore;
			
			try {
				memcachedDataStore = new MemcachedDataStore(settings);
			} catch (IOException e) {
				throw new WicketSpringBootException(e);
			}
			
			return new SessionQuotaManagingDataStore(memcachedDataStore, TypeParser.parse(prop.getSessionSize(), prop.getSessionUnit()));
		}
	});
	
	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", prop)
			.build());

}
 
Example #20
Source File: DiskStoreBrowserConfig.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	DebugPageManagerProvider pageManager = new DebugPageManagerProvider(webApplication);
	webApplication.setPageManagerProvider(pageManager);
	webApplication.mountPage(properties.getMountPage(), DiskStoreBrowserPage.class);
	
	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", properties)
			.build());
}
 
Example #21
Source File: RequestCycleSettingsConfig.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	RequestCycleSettings requestCycleSettings = webApplication.getRequestCycleSettings();
	
	requestCycleSettings.setRenderStrategy(props.getRenderStrategy());
	requestCycleSettings.setBufferResponse(props.isBufferResponse());
	requestCycleSettings.setExceptionRetryCount(props.getExceptionRetryCount());
	requestCycleSettings.setGatherExtendedBrowserInfo(props.isGatherExtendedBrowserInfo());
	requestCycleSettings.setResponseRequestEncoding(props.getResponseRequestEncoding());
	requestCycleSettings.setTimeout(TypeParser.parse(props.getTimeoutSize(), props.getTimeoutUnit()));
	
	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", props)
			.build());
}
 
Example #22
Source File: PackageResourceGuardConfig.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	IPackageResourceGuard packageResourceGuard = webApplication.getResourceSettings().getPackageResourceGuard();
	if (packageResourceGuard instanceof SecurePackageResourceGuard) {
		SecurePackageResourceGuard guard = (SecurePackageResourceGuard) packageResourceGuard;
		for(String pattern : props.getPattern()){
			guard.addPattern(pattern);
		}
	}
	
	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", props)
			.build());
	
}
 
Example #23
Source File: StatelessCheckerConfig.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	webApplication.getComponentPostOnBeforeRenderListeners().add(new StatelessChecker());
	
	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", props)
			.build());
	
}
 
Example #24
Source File: WicketSourceConfig.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	WicketSource.configure(webApplication);
	
	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", props)
			.build());
	
}
 
Example #25
Source File: BeanValidationConfig.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	BeanValidationConfiguration validationConfiguration = new BeanValidationConfiguration();
	validationConfiguration.setValidatorProvider(new IProvider<Validator>() {
		@Override
		public Validator get() {
			return validator;
		}
	});
	validationConfiguration.configure(webApplication);
	
	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", props)
			.build());
}
 
Example #26
Source File: RestAnnotationsConfig.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	String packagename = webApplication.getClass().getPackage().getName();
	if (prop.getPackagename() != null) {
		packagename = prop.getPackagename();
	}
	
	PackageScanner.scanPackage(webApplication, packagename);
	
	for (String basePackage : candidates.getBasePackages()) {
		PackageScanner.scanPackage(webApplication, basePackage);
	}
	
}
 
Example #27
Source File: WicketSerializerFast2Config.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	ISerializer currentSerializer = webApplication.getFrameworkSettings().getSerializer();
	if (currentSerializer.getClass().equals(JavaSerializer.class)) {
		webApplication.getFrameworkSettings().setSerializer(new Fast2WicketSerializer());
	} else {
		throw new ExtensionMisconfigurationException("Fast2Config: There is already another serializer configured " + currentSerializer);
	}
	
	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", props)
			.build());
	
}
 
Example #28
Source File: WicketSerializerKryo2Config.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	ISerializer currentSerializer = webApplication.getFrameworkSettings().getSerializer();
	if (currentSerializer.getClass().equals(JavaSerializer.class)) {
		webApplication.getFrameworkSettings().setSerializer(new KryoSerializer());
	} else {
		throw new ExtensionMisconfigurationException("Kryo2Config: There is already another serializer configured " + currentSerializer);
	}
	
	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", props)
			.build());
	
}
 
Example #29
Source File: SpringReferenceConfig.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	SpringReferenceSupporter.register(webApplication);
	
	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", props)
			.build());
}
 
Example #30
Source File: HTMLCompressingConfig.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void init(WebApplication webApplication) {
	
	HtmlCompressor compressor = new HtmlCompressor();
	setFeatureConfiguration(compressor);
	webApplication.getMarkupSettings().setMarkupFactory(new HtmlCompressingMarkupFactory(compressor));
	
	wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass())
			.withDetail("properties", props)
			.build());
}