Skip to content
Permalink
Browse files

Merge branch 'appng-1.20.x'

  • Loading branch information...
appng-buildmaster committed Sep 10, 2019
2 parents f0fe467 + a284ac2 commit 2fb30bc97f7d817c4a4d46eafdddebafa1868d11
Showing with 215 additions and 94 deletions.
  1. +2 −2 README.adoc
  2. +1 −1 appng-api/pom.xml
  3. +1 −1 appng-application-assembly/pom.xml
  4. +6 −6 appng-application-bom/pom.xml
  5. +1 −1 appng-application-camunda/pom.xml
  6. +1 −1 appng-application-parent/pom.xml
  7. +1 −1 appng-application/pom.xml
  8. +1 −1 appng-appngizer-jaxb/pom.xml
  9. +1 −1 appng-appngizer-maven-plugin/pom.xml
  10. +1 −1 appng-appngizer/pom.xml
  11. +1 −1 appng-archetype-application/pom.xml
  12. +1 −1 appng-archetype-application/readme.txt
  13. +1 −1 appng-archetype-application/src/main/resources/archetype-resources/pom.xml
  14. +1 −1 appng-camunda/pom.xml
  15. +1 −1 appng-cli/pom.xml
  16. +1 −1 appng-core/pom.xml
  17. +56 −16 appng-core/src/main/java/org/appng/core/controller/handler/GuiHandler.java
  18. +28 −13 appng-core/src/main/java/org/appng/core/domain/DatabaseConnection.java
  19. +21 −17 appng-core/src/main/java/org/appng/core/model/ThymeleafProcessor.java
  20. +3 −1 appng-core/src/test/java/org/appng/core/controller/handler/GuiHandlerTest.java
  21. +49 −0 appng-core/src/test/java/org/appng/core/domain/DatabaseTypeTest.java
  22. +1 −1 appng-documentation/pom.xml
  23. +4 −4 appng-documentation/src/main/asciidoc/listing/dependencies.txt
  24. +1 −1 appng-forms/pom.xml
  25. +1 −1 appng-formtags/pom.xml
  26. +1 −1 appng-mail/pom.xml
  27. +1 −1 appng-maven-plugin/pom.xml
  28. +1 −1 appng-persistence/pom.xml
  29. +1 −1 appng-rest-api/pom.xml
  30. +1 −1 appng-search/pom.xml
  31. +1 −1 appng-standalone/pom.xml
  32. +1 −1 appng-taglib/pom.xml
  33. +1 −1 appng-template-assembly/pom.xml
  34. +2 −2 appng-template-parent/pom.xml
  35. +1 −1 appng-testsupport/pom.xml
  36. +1 −1 appng-tools/pom.xml
  37. +1 −1 appng-upngizr/README.adoc
  38. +1 −1 appng-upngizr/pom.xml
  39. +1 −1 appng-xmlapi/pom.xml
  40. +11 −0 changelog.txt
  41. +3 −3 pom.xml
@@ -1,6 +1,6 @@
image::https://www.aiticon.com/assets/images/appng_logo_760px.jpg[]
:snapshot: 1.20.1-SNAPSHOT
:stable: 1.20.0
:snapshot: 1.20.2-SNAPSHOT
:stable: 1.20.1
:current: {stable}
ifdef::env-github[]
:caution-caption: :fire:
@@ -11,7 +11,7 @@
<parent>
<groupId>org.appng</groupId>
<artifactId>appng-parent</artifactId>
<version>1.20.0</version>
<version>1.20.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

@@ -8,7 +8,7 @@
<parent>
<groupId>org.appng</groupId>
<artifactId>appng-parent</artifactId>
<version>1.20.0</version>
<version>1.20.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

@@ -5,7 +5,7 @@
<artifactId>appng-application-bom</artifactId>
<packaging>pom</packaging>
<name>appNG application BOM</name>
<version>1.20.0</version>
<version>1.20.1</version>
<description>the bill of materials for an appNG application, defining all provided dependencies</description>
<organization>
<name>aiticon GmbH</name>
@@ -1018,19 +1018,19 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.4.Final</version>
<version>5.4.3.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.4.4.Final</version>
<version>5.4.3.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<version>5.4.4.Final</version>
<version>5.4.3.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -1186,13 +1186,13 @@
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>2.4.3.RELEASE</version>
<version>2.4.6.RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-xml</artifactId>
<version>2.4.3.RELEASE</version>
<version>2.4.6.RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -10,7 +10,7 @@
<parent>
<groupId>org.appng</groupId>
<artifactId>appng-parent</artifactId>
<version>1.20.0</version>
<version>1.20.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.appng</groupId>
<artifactId>appng-application-parent</artifactId>
<version>1.20.0</version>
<version>1.20.1</version>
<packaging>pom</packaging>
<name>appNG application parent</name>
<description>Parent pom for appNG applications</description>
@@ -10,7 +10,7 @@
<parent>
<groupId>org.appng</groupId>
<artifactId>appng-parent</artifactId>
<version>1.20.0</version>
<version>1.20.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

@@ -9,7 +9,7 @@
<parent>
<groupId>org.appng</groupId>
<artifactId>appng-parent</artifactId>
<version>1.20.0</version>
<version>1.20.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

@@ -14,7 +14,7 @@
<parent>
<groupId>org.appng</groupId>
<artifactId>appng-parent</artifactId>
<version>1.20.0</version>
<version>1.20.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

@@ -9,7 +9,7 @@
<parent>
<groupId>org.appng</groupId>
<artifactId>appng-parent</artifactId>
<version>1.20.0</version>
<version>1.20.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

@@ -8,6 +8,6 @@
<parent>
<groupId>org.appng</groupId>
<artifactId>appng-parent</artifactId>
<version>1.20.0</version>
<version>1.20.1</version>
</parent>
</project>
@@ -1,2 +1,2 @@
Usage:
mvn archetype:generate -DgroupId=mygroupid -DartifactId=myartifactid -DarchetypeGroupId=org.appng -DarchetypeArtifactId=appng-archetype-application -DarchetypeVersion=1.20.0 -DinteractiveMode=false
mvn archetype:generate -DgroupId=mygroupid -DartifactId=myartifactid -DarchetypeGroupId=org.appng -DarchetypeArtifactId=appng-archetype-application -DarchetypeVersion=1.20.1 -DinteractiveMode=false
@@ -9,7 +9,7 @@

<properties>
<outFolder>target</outFolder>
<appNG.version>1.20.0</appNG.version>
<appNG.version>1.20.1</appNG.version>
<displayName>myapplication</displayName>
<longDescription>enter long description here</longDescription>
<timestamp>${maven.build.timestamp}</timestamp>
@@ -11,7 +11,7 @@
<parent>
<groupId>org.appng</groupId>
<artifactId>appng-parent</artifactId>
<version>1.20.0</version>
<version>1.20.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

@@ -11,7 +11,7 @@
<parent>
<groupId>org.appng</groupId>
<artifactId>appng-parent</artifactId>
<version>1.20.0</version>
<version>1.20.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

@@ -11,7 +11,7 @@
<parent>
<groupId>org.appng</groupId>
<artifactId>appng-parent</artifactId>
<version>1.20.0</version>
<version>1.20.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

@@ -20,7 +20,8 @@
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.HashSet;
import java.util.Set;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -37,19 +38,21 @@
import org.appng.api.model.Application;
import org.appng.api.model.Properties;
import org.appng.api.model.Site;
import org.appng.api.model.Subject;
import org.appng.core.Redirect;
import org.appng.core.controller.HttpHeaders;
import org.appng.core.model.RequestProcessor;
import org.appng.core.service.TemplateService;
import org.appng.xml.application.Template;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpStatus;
import org.springframework.util.StopWatch;

import lombok.extern.slf4j.Slf4j;

/**
* A {@link RequestHandler} responsible for handling requests to the appNG GUI provided by the several
* {@link Application}s of a {@link Site}.
* A {@link RequestHandler} responsible for handling requests to the appNG GUI
* provided by the several {@link Application}s of a {@link Site}.
*
* @author Matthias Müller
*
@@ -92,19 +95,12 @@ public void handle(HttpServletRequest servletRequest, HttpServletResponse servle
private void processGui(HttpServletRequest servletRequest, HttpServletResponse servletResponse, Environment env,
Site site, Properties platformProperties, PathInfo pathInfo, String templateDir)
throws IOException, InvalidConfigurationException {
Subject subject = env.getSubject();
if (env.isSubjectAuthenticated() && !(pathInfo.hasSite() || pathInfo.hasApplication())) {
String applicationName = site.getProperties().getString(SiteProperties.DEFAULT_APPLICATION);
if (!site.hasApplication(applicationName)) {
Iterator<Application> iterator = site.getApplications().iterator();
while (iterator.hasNext()) {
Application application = iterator.next();
if (!application.isHidden()) {
applicationName = application.getName();
break;
}
}
}
site.sendRedirect(env, applicationName);
// no site and/or application has been set
String managerPath = site.getProperties().getString(SiteProperties.MANAGER_PATH);
String target = getForwardTargetForSite(managerPath, site, subject);
site.sendRedirect(env, target);
return;
}

@@ -115,7 +111,8 @@ private void processGui(HttpServletRequest servletRequest, HttpServletResponse s
Site applicationSite = RequestUtil.getSiteByName(env, siteName);

// "siteName" might be a reference to a certain application page
if (null == applicationSite) {
boolean isShortPath = null == applicationSite;
if (isShortPath) {
// assume site is current site
applicationSite = site;
}
@@ -133,6 +130,31 @@ private void processGui(HttpServletRequest servletRequest, HttpServletResponse s
pathInfo.setApplicationName(applicationName);
}

// check if user has access to the requested site and application
Application targetApp = applicationSite.getApplication(applicationName);
if (!isShortPath && env.isSubjectAuthenticated() && !subject.hasApplication(targetApp)) {
LOGGER.info("Subject '{}' does not have access to application '{}' on site '{}', trying to redirect.",
subject.getName(), applicationName, applicationSite.getName());
String managerPath = applicationSite.getProperties().getString(SiteProperties.MANAGER_PATH);
// try to find application on same site
String target = getForwardTargetForSite(managerPath, applicationSite, subject);

if (managerPath.equals(target)) {
// try to find application on any other site
Set<String> remainingSites = new HashSet<>(RequestUtil.getSiteNames(env));
remainingSites.remove(applicationSite.getName());
for (String otherSite : remainingSites) {
target = getForwardTargetForSite(managerPath, RequestUtil.getSiteByName(env, otherSite), subject);
if (!managerPath.equals(target)) {
break;
}
}
}
// Take it on the other side...Take it on, take it on
site.sendRedirect(env, target, HttpStatus.FOUND.value());
return;
}

HttpHeaders.setNoCache(servletResponse);

ApplicationContext ctx = env.getAttribute(PLATFORM, Platform.Environment.CORE_PLATFORM_CONTEXT);
@@ -168,4 +190,22 @@ private void processGui(HttpServletRequest servletRequest, HttpServletResponse s
}
}

private String getForwardTargetForSite(String managerPath, Site site, Subject subject) {
Application targetApp = null;
String applicationName = site.getProperties().getString(SiteProperties.DEFAULT_APPLICATION);
Application defaultApp = site.getApplication(applicationName);
if (null != defaultApp && !defaultApp.isHidden() && subject.hasApplication(defaultApp)) {
targetApp = defaultApp;
} else {
for (Application application : site.getApplications()) {
if (!application.isHidden() && subject.hasApplication(application)) {
targetApp = application;
break;
}
}
}
return null == targetApp ? managerPath
: String.format("%s/%s/%s", managerPath, site.getName(), targetApp.getName());
}

}
@@ -54,6 +54,7 @@
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.util.ClassUtils;

import lombok.extern.slf4j.Slf4j;

@@ -75,18 +76,28 @@

private static final String DATABASE_NAME = "databaseName=";
public static final String DB_PLACEHOLDER = "<name>";
private static String MYSQL_DATASOURCE = "com.mysql.cj.jdbc.MysqlDataSource";
private static final String MYSQL_LEGACY_DATASOURCE = "com.mysql.jdbc.jdbc2.optional.MysqlDataSource";

static {
if (ClassUtils.isPresent(MYSQL_LEGACY_DATASOURCE, null)) {
MYSQL_DATASOURCE = MYSQL_LEGACY_DATASOURCE;
}
}

/** enum-type for the supported databases */
public enum DatabaseType {

/** MySQL */
MYSQL("com.mysql.jdbc.Driver", "com.mysql.jdbc.jdbc2.optional.MysqlDataSource", "jdbc:mysql://localhost:3306/" + DB_PLACEHOLDER, "select 1"),
MYSQL("com.mysql.jdbc.Driver", MYSQL_DATASOURCE, "jdbc:mysql://localhost:3306/" + DB_PLACEHOLDER, "select 1"),

/** Microsoft SQL Server */
MSSQL("com.microsoft.sqlserver.jdbc.SQLServerDriver", "com.microsoft.sqlserver.jdbc.SQLServerDataSource", "jdbc:sqlserver://localhost:1433;databaseName=" + DB_PLACEHOLDER, "select 1"),
MSSQL("com.microsoft.sqlserver.jdbc.SQLServerDriver", "com.microsoft.sqlserver.jdbc.SQLServerDataSource",
"jdbc:sqlserver://localhost:1433;databaseName=" + DB_PLACEHOLDER, "select 1"),

/** HSQL DB */
HSQL("org.hsqldb.jdbc.JDBCDriver", "org.hsqldb.jdbc.JDBCDataSource", "jdbc:hsqldb:hsql://localhost:9001/" + DB_PLACEHOLDER, "select 1 from INFORMATION_SCHEMA.SYSTEM_USERS");
HSQL("org.hsqldb.jdbc.JDBCDriver", "org.hsqldb.jdbc.JDBCDataSource",
"jdbc:hsqldb:hsql://localhost:9001/" + DB_PLACEHOLDER, "select 1 from INFORMATION_SCHEMA.SYSTEM_USERS");

private final String defaultDriver;
private final String templateUrl;
@@ -125,6 +136,19 @@ public String getDataSourceClassName() {
return dataSourceClassName;
}

String getDatabaseName(String jdbcUrl) {
int paramStart = jdbcUrl.indexOf('?') < 0 ? jdbcUrl.length() : jdbcUrl.indexOf('?');
switch (this) {

case MSSQL:
return jdbcUrl.substring(jdbcUrl.lastIndexOf(DATABASE_NAME) + DATABASE_NAME.length(), paramStart);

default:
int beginIndex = jdbcUrl.indexOf('/', jdbcUrl.indexOf("//") + 2) + 1;
return jdbcUrl.substring(beginIndex, paramStart);
}
}

}

private Integer id;
@@ -426,16 +450,7 @@ public String getDatabaseConnectionString(String databaseName) {

@Transient
public String getDatabaseName() {
int paramStart = jdbcUrl.indexOf('?') < 0 ? jdbcUrl.length() : jdbcUrl.indexOf('?');
switch (type) {

case MSSQL:
String databaseName = "databaseName=";
return jdbcUrl.substring(getJdbcUrl().lastIndexOf(databaseName) + databaseName.length(), paramStart);

default:
return jdbcUrl.substring(getJdbcUrl().lastIndexOf('/') + 1, paramStart);
}
return type.getDatabaseName(jdbcUrl);
}

@Transient

0 comments on commit 2fb30bc

Please sign in to comment.
You can’t perform that action at this time.