/** * Copyright 2011 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bricket.web; import org.apache.wicket.AbstractRestartResponseException; import org.apache.wicket.RestartResponseAtInterceptPageException; import org.bricket.plugin.authentication.web.LoginPage; import org.bricket.web.common.info.WorkspaceIdTile; import org.bricket.web.common.link.DependingLinkTile; import org.springframework.security.core.context.SecurityContextHolder; import brix.Brix; import brix.Plugin; import brix.auth.AuthorizationStrategy; import brix.codepress.CodePressMarkupEditorFactory; import brix.config.BrixConfig; import brix.plugin.menu.MenuPlugin; import brix.plugin.prototype.PrototypePlugin; import brix.plugin.site.page.admin.MarkupEditorFactory; import brix.plugin.site.page.tile.Tile; import brix.plugin.snapshot.SnapshotPlugin; import brix.plugin.webdavurl.WebdavUrlPlugin; import brix.plugins.springsecurity.AuthorizationStrategyImpl; import brix.plugins.springsecurity.UserPlugin; import brix.tinymce.TinyMceMarkupEditorFactory; /** * @author Henning Teek * @author Ingo Renner */ public class Bricket extends Brix { private AuthorizationStrategyImpl authStrategy; public Bricket(BrixConfig config, AuthorizationStrategyImpl authStrategy) { super(config); this.authStrategy = authStrategy; // register plugins config.getRegistry().register(Plugin.POINT, new MenuPlugin(this)); config.getRegistry().register(Plugin.POINT, new SnapshotPlugin(this)); config.getRegistry().register(Plugin.POINT, new PrototypePlugin(this)); config.getRegistry().register(Plugin.POINT, new WebdavUrlPlugin()); config.getRegistry().register(Plugin.POINT, new UserPlugin(this)); // register markup editors config.getRegistry().register(MarkupEditorFactory.POINT, new TinyMceMarkupEditorFactory()); config.getRegistry().register(MarkupEditorFactory.POINT, new CodePressMarkupEditorFactory()); // Feedback config.getRegistry().register(Tile.POINT, new BricketFeedbackTile()); // Info config.getRegistry().register(Tile.POINT, new WorkspaceIdTile()); // Configurable link config.getRegistry().register(Tile.POINT, new DependingLinkTile()); } @Override public AuthorizationStrategy newAuthorizationStrategy() { return authStrategy; } public AbstractRestartResponseException getForbiddenException() { if (SecurityContextHolder.getContext().getAuthentication() == null) { return new RestartResponseAtInterceptPageException(LoginPage.class); } else { return super.getForbiddenException(); } } }