parent
6041e355a5
commit
dfe36e2614
|
|
@ -26,9 +26,7 @@ import freemarker.template.Configuration;
|
||||||
import freemarker.template.Template;
|
import freemarker.template.Template;
|
||||||
import freemarker.template.TemplateException;
|
import freemarker.template.TemplateException;
|
||||||
import freemarker.template.TemplateExceptionHandler;
|
import freemarker.template.TemplateExceptionHandler;
|
||||||
import org.libreccm.core.CoreConstants;
|
import org.libreccm.security.Shiro;
|
||||||
import org.libreccm.security.AuthorizationRequired;
|
|
||||||
import org.libreccm.security.RequiresPrivilege;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|
@ -44,9 +42,11 @@ import javax.ws.rs.NotFoundException;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.RedirectionException;
|
||||||
import javax.ws.rs.WebApplicationException;
|
import javax.ws.rs.WebApplicationException;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
import javax.ws.rs.core.UriBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -62,6 +62,9 @@ public class AdminUi {
|
||||||
@Inject
|
@Inject
|
||||||
private ServletContext servletContext;
|
private ServletContext servletContext;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Shiro shiro;
|
||||||
|
|
||||||
private Configuration configuration;
|
private Configuration configuration;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
|
|
@ -89,8 +92,8 @@ public class AdminUi {
|
||||||
@GET
|
@GET
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@Produces(MediaType.TEXT_HTML)
|
@Produces(MediaType.TEXT_HTML)
|
||||||
@AuthorizationRequired
|
// @AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
// @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
public String getDashboard() {
|
public String getDashboard() {
|
||||||
return getApp("dashboard");
|
return getApp("dashboard");
|
||||||
}
|
}
|
||||||
|
|
@ -98,9 +101,21 @@ public class AdminUi {
|
||||||
@GET
|
@GET
|
||||||
@Path("/{appName}")
|
@Path("/{appName}")
|
||||||
@Produces(MediaType.TEXT_HTML)
|
@Produces(MediaType.TEXT_HTML)
|
||||||
@AuthorizationRequired
|
// @AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
// @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
public String getApp(@PathParam("appName") final String appName) {
|
public String getApp(@PathParam("appName") final String appName) {
|
||||||
|
if (!shiro.getUser().isPresent()
|
||||||
|
|| !shiro.getSubject().isAuthenticated()) {
|
||||||
|
final UriBuilder uriBuilder = UriBuilder.fromUri("/ccm/register");
|
||||||
|
uriBuilder.queryParam(
|
||||||
|
"return_url",
|
||||||
|
String.format("%s/@admin", servletContext.getContextPath())
|
||||||
|
);
|
||||||
|
throw new RedirectionException(
|
||||||
|
Response.Status.TEMPORARY_REDIRECT, uriBuilder.build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
final AdminUiApp app = adminUiApps
|
final AdminUiApp app = adminUiApps
|
||||||
.getAdminUiApp(appName)
|
.getAdminUiApp(appName)
|
||||||
.orElseThrow(
|
.orElseThrow(
|
||||||
|
|
@ -125,6 +140,7 @@ public class AdminUi {
|
||||||
final Map<String, Object> data = new HashMap<>();
|
final Map<String, Object> data = new HashMap<>();
|
||||||
data.put("adminUiApps", adminUiApps.getAdminUiApps());
|
data.put("adminUiApps", adminUiApps.getAdminUiApps());
|
||||||
data.put("activeApp", app);
|
data.put("activeApp", app);
|
||||||
|
data.put("currentUser", shiro.getUser().get());
|
||||||
|
|
||||||
final StringWriter writer = new StringWriter();
|
final StringWriter writer = new StringWriter();
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA
|
# MA 02110-1301 USA
|
||||||
|
dashboard.label=Dashboard
|
||||||
|
dashboard.description=Dashboard
|
||||||
systeminformation.label=System Information
|
systeminformation.label=System Information
|
||||||
systeminformation.description=Shows several system properties
|
systeminformation.description=Shows several system properties
|
||||||
|
|
@ -17,3 +17,5 @@
|
||||||
|
|
||||||
systeminformation.label=System Informationen
|
systeminformation.label=System Informationen
|
||||||
systeminformation.description=Zeigt verschiedene Eigenschaften des Systems
|
systeminformation.description=Zeigt verschiedene Eigenschaften des Systems
|
||||||
|
dashboard.label=\u00dcbersicht
|
||||||
|
dashboard.description=\u00dcbersicht
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,55 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Admin UI</h1>
|
<h1>Admin UI</h1>
|
||||||
|
<p>
|
||||||
|
Current user ${currentUser.name}
|
||||||
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<#list adminUiApps as app>
|
<#list adminUiApps as app>
|
||||||
<li>${app.name}</li>
|
<li>
|
||||||
|
<dl>
|
||||||
|
<dt>Name</dt>
|
||||||
|
<dd>${app.name}</dd>
|
||||||
|
<dt>Label</dt>
|
||||||
|
<dd>${app.label}</dd>
|
||||||
|
<dt>Description</dt>
|
||||||
|
<dd>${app.description}</dd>
|
||||||
|
<dt>Order</dt>
|
||||||
|
<dd>${app.order}</dd>
|
||||||
|
<dt>JavascriptFiles</dt>
|
||||||
|
<dd>
|
||||||
|
<ul>
|
||||||
|
<#list app.jsFilesUrls as jsFile>
|
||||||
|
<li>${jsFile}</li>
|
||||||
|
</#list>
|
||||||
|
</ul>
|
||||||
|
</dd>
|
||||||
|
<dt>CssFiles</dt>
|
||||||
|
<dd>
|
||||||
|
<ul>
|
||||||
|
<#list app.cssFilesUrls as cssFile>
|
||||||
|
<li>${cssFile}</li>
|
||||||
|
</#list>
|
||||||
|
</ul>
|
||||||
|
</dd>
|
||||||
|
<dt>Icon Name</dt>
|
||||||
|
<dd>
|
||||||
|
<#if (app.iconName.isPresent())>
|
||||||
|
${app.iconName.get()}
|
||||||
|
<#else>
|
||||||
|
n/a
|
||||||
|
</#if>
|
||||||
|
</dd>
|
||||||
|
<dt>Symbol URL</dt>
|
||||||
|
<dd>
|
||||||
|
<#if (app.symbolUrl.isPresent())>
|
||||||
|
${app.symbolUrl.get()}
|
||||||
|
<#else>
|
||||||
|
n/a
|
||||||
|
</#if>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</li>
|
||||||
</#list>
|
</#list>
|
||||||
</ul>
|
</ul>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue