From a7a0b8ea01dca14602fdb49047d987c36461e861 Mon Sep 17 00:00:00 2001 From: James Moger Date: Sat, 16 Nov 2013 09:46:55 -0500 Subject: Refactor access to home page class Change-Id: Ice5706dc0659a44f54e5bf29ca66580e3be22418 --- src/main/java/com/gitblit/wicket/AuthorizationStrategy.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/gitblit/wicket/AuthorizationStrategy.java') diff --git a/src/main/java/com/gitblit/wicket/AuthorizationStrategy.java b/src/main/java/com/gitblit/wicket/AuthorizationStrategy.java index e3774d82..a00e2e2f 100644 --- a/src/main/java/com/gitblit/wicket/AuthorizationStrategy.java +++ b/src/main/java/com/gitblit/wicket/AuthorizationStrategy.java @@ -19,6 +19,7 @@ import org.apache.wicket.Component; import org.apache.wicket.RestartResponseException; import org.apache.wicket.authorization.IUnauthorizedComponentInstantiationListener; import org.apache.wicket.authorization.strategies.page.AbstractPageAuthorizationStrategy; +import org.apache.wicket.markup.html.WebPage; import com.gitblit.GitBlit; import com.gitblit.Keys; @@ -28,13 +29,16 @@ import com.gitblit.wicket.pages.BasePage; public class AuthorizationStrategy extends AbstractPageAuthorizationStrategy implements IUnauthorizedComponentInstantiationListener { - public AuthorizationStrategy() { + Class homepageClass; + + public AuthorizationStrategy(Class homepageClass) { + this.homepageClass = homepageClass; } @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected boolean isPageAuthorized(Class pageClass) { - if (GitBlitWebApp.HOME_PAGE_CLASS.equals(pageClass)) { + if (homepageClass.equals(pageClass)) { // allow all requests to get to the HomePage with its inline // authentication form return true; @@ -79,7 +83,7 @@ public class AuthorizationStrategy extends AbstractPageAuthorizationStrategy imp public void onUnauthorizedInstantiation(Component component) { if (component instanceof BasePage) { - throw new RestartResponseException(GitBlitWebApp.HOME_PAGE_CLASS); + throw new RestartResponseException(homepageClass); } } } -- cgit v1.2.3