You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by wch2001 <wc...@hotmail.com> on 2008/11/10 09:28:58 UTC

Help: webApplication can not go to loginPage,directory go to HomePage

Dear all,

Can you help  me to look at my webapplication, it can not call
loginpage(LoginPage.class) first, but directly call
homepage(IndexPage.class), thanks a lot

package sg.sphsearch.people.selfupdate.wicket.application;

import java.net.MalformedURLException;
import org.acegisecurity.AuthenticationManager;
import org.apache.wicket.Page;
import org.apache.wicket.Request;
import org.apache.wicket.RequestCycle;
import org.apache.wicket.Response;
import org.apache.wicket.Session;
import org.apache.wicket.WicketRuntimeException;
import
org.apache.wicket.extensions.ajax.markup.html.form.upload.UploadWebRequest;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.security.hive.HiveMind;
import org.apache.wicket.security.hive.authentication.LoginContext;
import org.apache.wicket.security.hive.config.PolicyFileHiveFactory;
import org.apache.wicket.security.swarm.SwarmWebApplication;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
import org.apache.wicket.util.lang.PackageName;
import org.apache.wicket.protocol.http.WebRequest;
import org.apache.wicket.protocol.http.WebRequestCycle;
import org.apache.wicket.protocol.http.WebResponse;
import sg.sphsearch.people.selfupdate.wicket.page.IndexPage;
import sg.sphsearch.people.selfupdate.wicket.page.RegistrationPage;
import sg.sphsearch.people.selfupdate.wicket.security.AcegiLoginContext;
import sg.sphsearch.people.selfupdate.wicket.security.LoginPage;
import
sg.sphsearch.people.selfupdate.wicket.security.SelfupdateRequestCycle;
import javax.servlet.http.HttpServletRequest;
import sg.sphsearch.people.selfupdate.wicket.security.ErrorPage;
import sg.sphsearch.people.selfupdate.wicket.security.ExpiredPage;
/**
 * 
 * @author jmulyadi
 *
 */
public class PeopleSelfUpdateApplication extends SwarmWebApplication
implements AcegiApplication {

    private AuthenticationManager authenticationManager;

    @Override
    protected void init() {
        super.init();
        addComponentInstantiationListener(new
SpringComponentInjector(this));
        getMarkupSettings().setCompressWhitespace(true);
        getMarkupSettings().setStripComments(true);
        getMarkupSettings().setStripWicketTags(true);
        getRequestCycleSettings().setResponseRequestEncoding("UTF-8");

        getResourceSettings().addResourceFolder("/WEB-INF/html/");
        getResourceSettings().setResourceStreamLocator(new
CustomResourceStreamLocator());
        getResourceSettings().setThrowExceptionOnMissingResource(false);

//         mountBookmarkablePage("/register", RegistrationPage.class); 
//         mountBookmarkablePage("/app", IndexPage.class);

        mount("/app", PackageName.forPackage(IndexPage.class.getPackage()));

//         mount("/register",
PackageName.forPackage(PeopleRegistrationPage.class.getPackage()));

    }

    @Override
    public Class getHomePage() {
        return IndexPage.class;
    }

    @Override
    public Session newSession(Request request, Response response) {
        return new SelfupdateAuthenticatedWebSession(this, request);
    }
    
    @Override
    protected WebRequest newWebRequest(HttpServletRequest servletRequest) {
        return new UploadWebRequest(servletRequest);
    }
    
    @Override
    protected void setUpHive() {
        //PolicyFileHiveFactory factory = new
PolicyFileHiveFactory(getActionFactory());  
        PolicyFileHiveFactory factory = new
PolicyFileHiveFactory(getActionFactory());
        try {
           
factory.addPolicyFile(getServletContext().getResource("/WEB-INF/policy/selfupdate.hive"));
            factory.setAlias("principal",
"sg.sphsearch.auth.domain.Principal");
            factory.setAlias("base",
"sg.sphsearch.people.selfupdate.wicket");

        //this application currently uses 1 policy file but you can add as
many as you like
        //factory.addPolicyFile(...);            
        } catch (MalformedURLException e) {
            throw new WicketRuntimeException(e);
        }
        HiveMind.registerHive(getHiveKey(), factory);
    }

    @Override
    protected Object getHiveKey() {
        return getServletContext().getContextPath();

    }
    @Override
    public Class getLoginPage() {
         return LoginPage.class;
    }
    public LoginContext getLogoffContext() {
        return new AcegiLoginContext();
    }

    @Override
    public AuthenticationManager getAuthenticationManager() {
        return authenticationManager;
    }

    public void setAuthenticationManager(final AuthenticationManager
authenticationManager) {
        this.authenticationManager = authenticationManager;
    }
    
    @Override
    public RequestCycle newRequestCycle(final Request request, final
Response response) {
    	
        return new WebRequestCycle((WebApplication) this, (WebRequest)
request, (WebResponse) response) {
            @Override
            public Page onRuntimeException(Page page, RuntimeException e) {
                if (page == null) {
                    return new ExpiredPage();
                }
                //logger.error(e.getMessage());
                return new ErrorPage();
            }
        };
    } 
  
}
-- 
View this message in context: http://www.nabble.com/Help%3A-webApplication-can-not-go-to-loginPage%2Cdirectory-go-to-HomePage-tp20416077p20416077.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org