--- /dev/null
+<html
+ xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+<head>
+ <title>Wicket Quickstart Archetype Homepage</title>
+</head>
+<body>
+<strong>Wicket Quickstart Archetype Homepage</strong>
+<br/>
+<br/>
+
+<wicket:extend>
+
+</wicket:extend>
+
+</body>
+</html>
--- /dev/null
+/*
+ * Copyright 2005-2010 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.wamblee.photos.wicket;
+
+import java.util.logging.Logger;
+
+import org.apache.wicket.PageParameters;
+
+/**
+ * Homepage
+ */
+public class AdminPage extends BasePage {
+
+ private static final Logger LOGGER = Logger.getLogger(AdminPage.class.getName());
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor that is invoked when page is invoked without a session.
+ *
+ * @param parameters Page parameters
+ */
+ public AdminPage(final PageParameters parameters) throws Exception {
+ super();
+ }
+
+ @Override
+ protected boolean isAdminPage() {
+ return true;
+ }
+}
\ No newline at end of file
<html
- xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+ xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
<head>
-<wicket:head>
- <title wicket:id="title">Title goes here</title>
-</wicket:head>
+ <wicket:head>
+ <title wicket:id="title">Title goes here</title>
+ </wicket:head>
</head>
<body>
- <div id="banner">
- <wicket:link>
- <img src="wamblee_logo.png" />
- </wicket:link>
- <span class="title">wamblee photos</span>
- </div>
- <div id="logout">
- <a href="#" wicket:id="logout">Logout</a>
- </div>
+<div id="banner">
+ <wicket:link>
+ <img src="wamblee_logo.png"/>
+ </wicket:link>
+ <span class="title">wamblee photos</span>
+</div>
+<div id="logout">
+ <a href="#" wicket:id="logout">Logout</a>
+</div>
- <div id="menu">
- <wicket:link>
- <ul>
- <li><a href="HomePage.html">Home</a></li>
- </ul>
- </wicket:link>
- </div>
+<div id="menu">
+ <wicket:link>
+ <ul>
+ <li><a href="HomePage.html">Home</a></li>
+ <li><a href="EditProfilePage.html">Edit Profile</a></li>
+ <li wicket:id="adminAccess">
+ <a href="AdminPage.html">Administration</a>
+ </li>
+ </ul>
+ </wicket:link>
- <div id="feedback">
- <div wicket:id="feedback"></div>
- </div>
+</div>
- <div id="content">
- <wicket:child />
- </div>
+<div id="feedback">
+ <div wicket:id="feedback"></div>
+</div>
+
+<div id="content">
+ <wicket:child/>
+</div>
</body>
</html>
*/
package org.wamblee.photos.wicket;
+import java.security.Principal;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import org.apache.wicket.RedirectToUrlException;
import org.apache.wicket.markup.html.CSSPackageResource;
+import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.IModel;
+import org.wamblee.security.authentication.UserAdministration;
import org.wamblee.wicket.behavior.TitleAttributeTooltipBehavior;
import org.wamblee.wicket.css.ResetCssBehavior;
import org.wamblee.wicket.page.ExpireBehavior;
@Inject
private HttpServletRequest request;
+ @Inject
+ private UserAdministration userAdmin;
+
private boolean isExpired = false;
public BasePage() {
public BasePage(IModel aModel) {
super(aModel);
- if (request.getUserPrincipal() == null) {
- redirectToLoginPage();
+ Principal userPrincipal = request.getUserPrincipal();
+ if (userPrincipal == null) {
+ throw redirectToLoginPage();
+ }
+ String username = userPrincipal.getName();
+ if (isAdminPage() && !isAdministrator(username)) {
+ error("Unauthorized URL accessed");
+ throw redirectToLoginPage();
}
add(new ResetCssBehavior());
throw redirectToLoginPage();
}
});
+
+ WebMarkupContainer adminAccess = new WebMarkupContainer("adminAccess");
+ if (!isAdministrator(username)) {
+ adminAccess.setVisible(false);
+ }
+ add(adminAccess);
+ }
+
+ protected boolean isAdminPage() {
+ return false;
+ }
+
+ protected boolean isAdministrator(String aUsername) {
+ return userAdmin.isInGroup(aUsername, "administrators");
}
private RedirectToUrlException redirectToLoginPage() {
--- /dev/null
+<html
+ xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+<head>
+ <title>Wicket Quickstart Archetype Homepage</title>
+</head>
+<body>
+<strong>Wicket Quickstart Archetype Homepage</strong>
+<br/>
+<br/>
+
+<wicket:extend>
+
+</wicket:extend>
+
+</body>
+</html>
--- /dev/null
+/*
+ * Copyright 2005-2010 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.wamblee.photos.wicket;
+
+import java.util.logging.Logger;
+
+import org.apache.wicket.PageParameters;
+
+/**
+ * Homepage
+ */
+public class EditProfilePage extends BasePage {
+
+ private static final Logger LOGGER = Logger.getLogger(EditProfilePage.class.getName());
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor that is invoked when page is invoked without a session.
+ *
+ * @param parameters Page parameters
+ */
+ public EditProfilePage(final PageParameters parameters) throws Exception {
+ super();
+ }
+}
\ No newline at end of file