You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2014/05/05 19:00:12 UTC

[2/2] git commit: ISIS-774: removing IsisWicketUnsecuredApplication

ISIS-774: removing IsisWicketUnsecuredApplication

... since is not being maintained/used.


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/58fa0b87
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/58fa0b87
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/58fa0b87

Branch: refs/heads/master
Commit: 58fa0b87d02f40cc607717bc3286929c6bd55e68
Parents: a0c9a70
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Mon May 5 17:59:56 2014 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon May 5 17:59:56 2014 +0100

----------------------------------------------------------------------
 .../viewer/IsisWicketUnsecuredApplication.java  | 337 -------------------
 1 file changed, 337 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/58fa0b87/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketUnsecuredApplication.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketUnsecuredApplication.java b/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketUnsecuredApplication.java
deleted file mode 100644
index e5cab8e..0000000
--- a/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketUnsecuredApplication.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you 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.apache.isis.viewer.wicket.viewer;
-
-import java.util.List;
-
-import javax.servlet.ServletContext;
-
-import com.google.inject.Guice;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.google.inject.Module;
-
-import de.agilecoders.wicket.webjars.WicketWebjars;
-import de.agilecoders.wicket.webjars.settings.WebjarsSettings;
-
-import org.apache.wicket.ConverterLocator;
-import org.apache.wicket.IConverterLocator;
-import org.apache.wicket.Page;
-import org.apache.wicket.Session;
-import org.apache.wicket.guice.GuiceComponentInjector;
-import org.apache.wicket.protocol.http.WebApplication;
-import org.apache.wicket.request.Request;
-import org.apache.wicket.request.Response;
-import org.apache.wicket.settings.IRequestCycleSettings.RenderStrategy;
-
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.authentication.AuthenticationSessionProvider;
-import org.apache.isis.core.commons.authentication.AuthenticationSessionProviderAware;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.commons.config.IsisConfigurationBuilder;
-import org.apache.isis.core.commons.config.IsisConfigurationBuilderPrimer;
-import org.apache.isis.core.commons.config.IsisConfigurationBuilderResourceStreams;
-import org.apache.isis.core.commons.resource.ResourceStreamSource;
-import org.apache.isis.core.commons.resource.ResourceStreamSourceContextLoaderClassPath;
-import org.apache.isis.core.commons.resource.ResourceStreamSourceCurrentClassClassPath;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.runtime.authentication.AuthenticationManager;
-import org.apache.isis.core.runtime.authentication.AuthenticationRequest;
-import org.apache.isis.core.runtime.authentication.standard.AuthenticationManagerStandard;
-import org.apache.isis.core.runtime.authentication.standard.AuthenticatorAbstract;
-import org.apache.isis.core.runtime.logging.IsisLoggingConfigurer;
-import org.apache.isis.core.runtime.runner.IsisInjectModule;
-import org.apache.isis.core.runtime.system.DeploymentType;
-import org.apache.isis.core.runtime.system.IsisSystem;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.webapp.WebAppConstants;
-import org.apache.isis.core.webapp.config.ResourceStreamSourceForWebInf;
-import org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento;
-import org.apache.isis.viewer.wicket.model.models.BookmarkedPagesModel;
-import org.apache.isis.viewer.wicket.model.models.ImageResourceCache;
-import org.apache.isis.viewer.wicket.model.models.PageType;
-import org.apache.isis.viewer.wicket.ui.app.registry.ComponentFactoryRegistry;
-import org.apache.isis.viewer.wicket.ui.app.registry.ComponentFactoryRegistryAccessor;
-import org.apache.isis.viewer.wicket.ui.pages.BookmarkedPagesModelProvider;
-import org.apache.isis.viewer.wicket.ui.pages.PageClassRegistry;
-import org.apache.isis.viewer.wicket.ui.pages.PageClassRegistryAccessor;
-import org.apache.isis.viewer.wicket.viewer.integration.isis.WicketServer;
-import org.apache.isis.viewer.wicket.viewer.integration.isis.WicketServerPrototype;
-import org.apache.isis.viewer.wicket.viewer.integration.wicket.AnonymousWebSessionForIsis;
-import org.apache.isis.viewer.wicket.viewer.integration.wicket.ConverterForObjectAdapter;
-import org.apache.isis.viewer.wicket.viewer.integration.wicket.ConverterForObjectAdapterMemento;
-import org.apache.isis.viewer.wicket.viewer.integration.wicket.WebRequestCycleForIsis;
-
-public class IsisWicketUnsecuredApplication extends WebApplication implements ComponentFactoryRegistryAccessor, PageClassRegistryAccessor, AuthenticationSessionProvider {
-
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * Convenience locator, downcasts inherited functionality.
-     */
-    public static IsisWicketUnsecuredApplication get() {
-        return (IsisWicketUnsecuredApplication) WebApplication.get();
-    }
-
-    private final IsisLoggingConfigurer loggingConfigurer = new IsisLoggingConfigurer();
-
-    /**
-     * {@link Inject}ed when {@link #init() initialized}.
-     */
-    @Inject
-    private ComponentFactoryRegistry componentFactoryRegistry;
-
-    /**
-     * {@link Inject}ed when {@link #init() initialized}.
-     */
-    @Inject
-    private ImageResourceCache imageCache;
-
-    /**
-     * {@link Inject}ed when {@link #init() initialized}.
-     */
-    @Inject
-    private PageClassRegistry pageClassRegistry;
-
-    /**
-     * {@link Inject}ed when {@link #init() initialized}.
-     */
-    @Inject
-    private IsisSystem system;
-
-    private BookmarkedPagesModel bookmarkedPagesModel;
-
-    // /////////////////////////////////////////////////
-    // constructor, init
-    // /////////////////////////////////////////////////
-
-    public IsisWicketUnsecuredApplication() {
-    }
-
-    /**
-     * Initializes the application; in particular, bootstrapping the Isis
-     * backend, and initializing the {@link ComponentFactoryRegistry} to be used
-     * for rendering.
-     */
-    @Override
-    protected void init() {
-        super.init();
-
-        // install 2 default collector instances 
-        // (FileAssetPathCollector(WEBJARS_PATH_PREFIX), JarAssetPathCollector)
-        // and a webjars resource finder.
-        WebjarsSettings settings = new WebjarsSettings();
-
-        WicketWebjars.install(this, settings);
-        
-        String isisConfigDir = getServletContext().getInitParameter("isis.config.dir");
-        final String loggingPropertiesDir;
-        if(isisConfigDir != null) {
-            loggingPropertiesDir = isisConfigDir;
-        } else {
-            loggingPropertiesDir = getServletContext().getRealPath("/WEB-INF");
-        }
-
-        loggingConfigurer.configureLogging(loggingPropertiesDir, new String[0]);
-
-        getRequestCycleSettings().setRenderStrategy(RenderStrategy.REDIRECT_TO_RENDER);
-
-        getRequestCycleListeners().add(new WebRequestCycleForIsis());
-
-        getResourceSettings().setParentFolderPlaceholder("$up$");
-
-        final DeploymentType deploymentType = determineDeploymentType();
-
-        final IsisConfigurationBuilder isisConfigurationBuilder = createConfigBuilder(getServletContext());
-
-        final IsisInjectModule isisModule = new IsisInjectModule(deploymentType, isisConfigurationBuilder);
-        final Injector injector = Guice.createInjector(isisModule, newIsisWicketModule());
-        injector.injectMembers(this);
-
-        this.bookmarkedPagesModel = new BookmarkedPagesModel();
-
-        initWicketComponentInjection(injector);
-    }
-
-    private DeploymentType determineDeploymentType() {
-        return usesDevelopmentConfig() ? new WicketServerPrototype() : new WicketServer();
-    }
-
-    private IsisConfigurationBuilder createConfigBuilder(ServletContext servletContext) {
-        final ResourceStreamSource rssServletContext = new ResourceStreamSourceForWebInf(getServletContext());
-        final ResourceStreamSource rssTcl = ResourceStreamSourceContextLoaderClassPath.create();
-        final ResourceStreamSource rssClasspath = new ResourceStreamSourceCurrentClassClassPath();
-        final IsisConfigurationBuilder isisConfigurationBuilder = new IsisConfigurationBuilderResourceStreams(rssTcl, rssClasspath, rssServletContext);
-        primeConfigurationBuilder(isisConfigurationBuilder, servletContext);
-        isisConfigurationBuilder.addDefaultConfigurationResources();
-        return isisConfigurationBuilder;
-    }
-
-    @SuppressWarnings("unchecked")
-    private static void primeConfigurationBuilder(final IsisConfigurationBuilder isisConfigurationBuilder, final ServletContext servletContext) {
-        final List<IsisConfigurationBuilderPrimer> isisConfigurationBuilderPrimers = (List<IsisConfigurationBuilderPrimer>) servletContext.getAttribute(WebAppConstants.CONFIGURATION_PRIMERS_KEY);
-        if (isisConfigurationBuilderPrimers == null) {
-            return;
-        }
-        for (final IsisConfigurationBuilderPrimer isisConfigurationBuilderPrimer : isisConfigurationBuilderPrimers) {
-            isisConfigurationBuilderPrimer.primeConfigurationBuilder(isisConfigurationBuilder);
-        }
-    }
-
-    protected void initWicketComponentInjection(final Injector injector) {
-        getComponentInstantiationListeners().add(new GuiceComponentInjector(this, injector, false));
-    }
-
-    /**
-     * Override if required
-     */
-    protected Module newIsisWicketModule() {
-        return new IsisWicketModule();
-    }
-
-    // /////////////////////////////////////////////////
-    // Wicket Hooks
-    // /////////////////////////////////////////////////
-
-    @Override
-    public Session newSession(final Request request, final Response response) {
-        final AuthenticationManager authenticationManager = anonymousAuthenticationManager();
-
-        final AnonymousWebSessionForIsis anonymousWebSession = new AnonymousWebSessionForIsis(request, authenticationManager);
-        anonymousWebSession.authenticate(null, null);
-        return anonymousWebSession;
-    }
-
-    private AuthenticationManager authenticationManager;
-
-    /**
-     * Lazily creates an {@link AuthenticationManager} that will authenticate
-     * all requests.
-     */
-    private AuthenticationManager anonymousAuthenticationManager() {
-        if (authenticationManager == null) {
-            final IsisConfiguration configuration = IsisContext.getConfiguration();
-            final AuthenticationManagerStandard authenticationManager = new AuthenticationManagerStandard(configuration);
-            authenticationManager.addAuthenticator(new AuthenticatorAbstract(configuration) {
-                @Override
-                public boolean isValid(final AuthenticationRequest request) {
-                    return true;
-                }
-
-                @Override
-                public boolean canAuthenticate(final Class<? extends AuthenticationRequest> authenticationRequestClass) {
-                    return true;
-                }
-            });
-            authenticationManager.init();
-            this.authenticationManager = authenticationManager;
-        }
-        return authenticationManager;
-    }
-
-//    /**
-//     * Installs a {@link WebRequestCycleForIsis custom implementation} of
-//     * Wicket's own {@link RequestCycle}, hooking in to provide session and
-//     * transaction management across potentially multiple concurrent requests
-//     * for the same Wicket session.
-//     *
-//     * <p>
-//     * In general, it shouldn't be necessary to override this method.
-//     */
-//    @Override
-//    public RequestCycle newRequestCycle(final Request request, final Response response) {
-//        return new WebRequestCycleForIsis(this, (WebRequest) request, response);
-//    }
-
-    /**
-     * Installs a {@link ConverterLocator} preconfigured with a number of
-     * implementations to support Isis specific objects.
-     *
-     * <p>
-     * In general, it shouldn't be necessary to override this method.
-     */
-    @Override
-    protected IConverterLocator newConverterLocator() {
-        final ConverterLocator converterLocator = new ConverterLocator();
-        converterLocator.set(ObjectAdapter.class, new ConverterForObjectAdapter());
-        converterLocator.set(ObjectAdapterMemento.class, new ConverterForObjectAdapterMemento());
-        return converterLocator;
-    }
-
-    // /////////////////////////////////////////////////
-    // Component Factories
-    // /////////////////////////////////////////////////
-
-    /**
-     * The {@link ComponentFactoryRegistry} created in
-     * {@link #newComponentFactoryRegistry()}.
-     */
-    @Override
-    public final ComponentFactoryRegistry getComponentFactoryRegistry() {
-        return componentFactoryRegistry;
-    }
-
-    // /////////////////////////////////////////////////
-    // Page Registry
-    // /////////////////////////////////////////////////
-
-    /**
-     * Access to other page types.
-     *
-     * <p>
-     * Non-final only for testing purposes; should not typically be overridden.
-     */
-    @Override
-    public PageClassRegistry getPageClassRegistry() {
-        return pageClassRegistry;
-    }
-
-    /**
-     * Delegates to the {@link #getPageClassRegistry() PageClassRegistry}.
-     */
-    @Override
-    public Class<? extends Page> getHomePage() {
-        return getPageClassRegistry().getPageClass(PageType.HOME);
-    }
-
-
-    // /////////////////////////////////////////////////
-    // Authentication Session
-    // /////////////////////////////////////////////////
-
-    @Override
-    public AuthenticationSession getAuthenticationSession() {
-        return IsisContext.getAuthenticationSession();
-    }
-
-
-    // /////////////////////////////////////////////////
-    // *Provider impl.
-    // /////////////////////////////////////////////////
-
-    @Override
-    public void injectInto(final Object candidate) {
-        if (AuthenticationSessionProviderAware.class.isAssignableFrom(candidate.getClass())) {
-            final AuthenticationSessionProviderAware cast = AuthenticationSessionProviderAware.class.cast(candidate);
-            cast.setAuthenticationSessionProvider(this);
-        }
-    }
-
-}