Integreted Apache Wicket

Former-commit-id: a6b20a34bf
wicket
Jens Pelzetter 2020-08-30 12:37:32 +02:00
parent 92a463ec5d
commit bad299d974
11 changed files with 308 additions and 4 deletions

View File

@ -84,8 +84,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>11</source>
<target>11</target>
<optimize>true</optimize>
<debug>true</debug>
<encoding>${project.build.sourceEncoding}</encoding>
@ -244,6 +244,9 @@
<configuration>
<skip>false</skip>
<propertiesFile>${project.basedir}/wildfly.properties</propertiesFile>
<env>
<wicket.configuration>development</wicket.configuration>
</env>
</configuration>
</plugin>

View File

@ -250,6 +250,12 @@
<artifactId>Saxon-HE</artifactId>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
<version>9.0.0</version>
</dependency>
<!-- Export Import Libraries -->
<dependency>

View File

@ -0,0 +1,99 @@
/*
* Copyright (C) 2020 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.ui;
import org.apache.wicket.protocol.http.WicketFilter;
import org.libreccm.core.CoreConstants;
import org.libreccm.security.PermissionChecker;
import org.libreccm.security.Shiro;
import java.io.IOException;
import java.net.URL;
import java.net.http.HttpRequest;
import javax.inject.Inject;
import javax.servlet.FilterChain;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@WebFilter(
value = "/@admin/",
initParams = {
@WebInitParam(
name = "applicationClassName",
value = "org.libreccm.ui.admin.CcmAdmin"
),
@WebInitParam(name = "filterMappingUrlPattern", value = "/@admin/*")
}
)
public class CcmAdminFilter extends WicketFilter {
@Inject
private Shiro shiro;
@Inject
private PermissionChecker permissionChecker;
@Inject
private ServletContext servletContext;
@Override
public void doFilter(
final ServletRequest request,
final ServletResponse response,
final FilterChain chain
) throws IOException, ServletException {
if (permissionChecker.isPermitted(CoreConstants.PRIVILEGE_ADMIN)) {
super.doFilter(request, response, chain);
} else if (shiro.getSubject().isAuthenticated()) {
final HttpServletResponse httpResponse
= (HttpServletResponse) response;
httpResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED);
} else {
final HttpServletRequest httpRequest = (HttpServletRequest) request;
final HttpServletResponse httpResponse
= (HttpServletResponse) response;
final String returnUrl = String.format(
"%s%s",
httpRequest.getContextPath(),
httpRequest.getServletPath()
);
httpResponse.sendRedirect(
String.format(
"%s/ccm/register?return_url=%s",
servletContext.getContextPath(),
returnUrl
)
);
}
}
}

View File

@ -0,0 +1,31 @@
/*
* Copyright (C) 2020 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.ui.admin;
import org.apache.wicket.markup.html.WebPage;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class AdminPage extends WebPage {
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,41 @@
/*
* Copyright (C) 2020 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.ui.admin;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.protocol.http.WebApplication;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class CcmAdmin extends WebApplication {
@Override
public Class<? extends WebPage> getHomePage() {
return DashboardPage.class;
}
@Override
public void init() {
super.init();
// setConfigurationType(RuntimeConfigurationType.DEPLOYMENT);
}
}

View File

@ -0,0 +1,35 @@
/*
* Copyright (C) 2020 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.ui.admin;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class DashboardPage extends AdminPage {
private static final long serialVersionUID = 1L;
@SuppressWarnings("OverridableMethodCallInConstructor")
public DashboardPage() {
// add(new Label("dashboardLabel", "CCM Admin Dashboard"));
add(new DashboardPanel("adminPanel"));
}
}

View File

@ -0,0 +1,38 @@
/*
* Copyright (C) 2020 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.ui.admin;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class DashboardPanel extends Panel {
private static final long serialVersionUID = 1L;
@SuppressWarnings("OverridableMethodCallInConstructor")
public DashboardPanel(String id) {
super(id);
add(new Label("dashboardLabel", "CCM Admin Dashboard"));
}
}

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>LibreCCM Admin</title>
</head>
<body>
<div wicket:id="adminPanel">[admin panel]</div>
</body>
</html>

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<wicket:panel>
<div wicket:id="dashboardLabel">
[Label's message goes here]
</div>
</wicket:panel>
</body>
</html>

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Dashboard - LibreCCM Admin</title>
</head>
<body>
<div wicket:id="dashboardLabel">
[Label's message goes here]
</div>
</body>
</html>

15
pom.xml
View File

@ -164,8 +164,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>11</source>
<target>11</target>
<optimize>true</optimize>
<debug>true</debug>
<encoding>${project.build.sourceEncoding}</encoding>
@ -556,6 +556,17 @@
<version>0.11.2</version>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
<version>9.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-cdi</artifactId>
<version>9.0.0</version>
</dependency>
<!--
*********************
Libraries used by CCM