Cleaned up a bit

This commit is contained in:
Kai Zimmermann
2016-03-15 13:22:43 +01:00
parent 40e8fdf5e0
commit f5352b420d
3 changed files with 130 additions and 113 deletions

View File

@@ -27,8 +27,6 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
* {@link TenantAware#getCurrentTenant()} in the eclipselink session. This has * {@link TenantAware#getCurrentTenant()} in the eclipselink session. This has
* to be done in eclipselink after a {@link Transaction} has been started. * to be done in eclipselink after a {@link Transaction} has been started.
* *
*
*
*/ */
public class MultiTenantJpaTransactionManager extends JpaTransactionManager { public class MultiTenantJpaTransactionManager extends JpaTransactionManager {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -44,13 +42,8 @@ public class MultiTenantJpaTransactionManager extends JpaTransactionManager {
.getResource(getEntityManagerFactory()); .getResource(getEntityManagerFactory());
final EntityManager em = emHolder.getEntityManager(); final EntityManager em = emHolder.getEntityManager();
if (!definition.getName().startsWith(SystemManagement.class.getCanonicalName() + ".findTenants") if (notTenantManagement(definition) && notCurrentTenantKeyGenerator(definition)
&& !definition.getName().startsWith(SystemManagement.class.getCanonicalName() + ".deleteTenant") && notRolloutScheduler(definition) && notGetOrCreateTenantMetadata(definition)) {
&& !definition.getName()
.startsWith(SystemManagement.class.getCanonicalName() + ".currentTenantKeyGenerator")
&& !definition.getName().startsWith(RolloutManagement.class.getCanonicalName() + ".rolloutScheduler")
&& !definition.getName()
.startsWith(SystemManagement.class.getCanonicalName() + ".getOrCreateTenantMetadata")) {
final String currentTenant = tenantAware.getCurrentTenant(); final String currentTenant = tenantAware.getCurrentTenant();
if (currentTenant == null) { if (currentTenant == null) {
@@ -60,4 +53,23 @@ public class MultiTenantJpaTransactionManager extends JpaTransactionManager {
em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase()); em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase());
} }
} }
private boolean notGetOrCreateTenantMetadata(final TransactionDefinition definition) {
return !definition.getName()
.startsWith(SystemManagement.class.getCanonicalName() + ".getOrCreateTenantMetadata");
}
private boolean notRolloutScheduler(final TransactionDefinition definition) {
return !definition.getName().startsWith(RolloutManagement.class.getCanonicalName() + ".rolloutScheduler");
}
private boolean notCurrentTenantKeyGenerator(final TransactionDefinition definition) {
return !definition.getName()
.startsWith(SystemManagement.class.getCanonicalName() + ".currentTenantKeyGenerator");
}
private boolean notTenantManagement(final TransactionDefinition definition) {
return !definition.getName().startsWith(SystemManagement.class.getCanonicalName() + ".deleteTenant")
&& !definition.getName().startsWith(SystemManagement.class.getCanonicalName() + ".findTenants");
}
} }

View File

@@ -142,6 +142,11 @@ public class HawkbitSecurityProperties {
this.maxAttributeEntriesPerTarget = maxAttributeEntriesPerTarget; this.maxAttributeEntriesPerTarget = maxAttributeEntriesPerTarget;
} }
/**
* Configuration for hawkBits DOS prevention filter. This is usually an
* infrastructure topic but might be useful in some cases.
*
*/
public static class Filter { public static class Filter {
/** /**

View File

@@ -19,22 +19,6 @@ import org.springframework.stereotype.Component;
@ConfigurationProperties("hawkbit.server.ui") @ConfigurationProperties("hawkbit.server.ui")
public class UiProperties { public class UiProperties {
private final Links links = new Links();
private final Login login = new Login();
private final Demo demo = new Demo();
public Login getLogin() {
return login;
}
public Links getLinks() {
return links;
}
public Demo getDemo() {
return demo;
}
/** /**
* Demo account login information. * Demo account login information.
* *
@@ -55,54 +39,37 @@ public class UiProperties {
*/ */
private String password = ""; private String password = "";
public String getTenant() { public String getPassword() {
return tenant; return password;
} }
public void setTenant(final String tenant) { public String getTenant() {
this.tenant = tenant; return tenant;
} }
public String getUser() { public String getUser() {
return user; return user;
} }
public void setUser(final String user) {
this.user = user;
}
public String getPassword() {
return password;
}
public void setPassword(final String password) { public void setPassword(final String password) {
this.password = password; this.password = password;
} }
public void setTenant(final String tenant) {
this.tenant = tenant;
} }
public void setUser(final String user) {
this.user = user;
}
}
/** /**
* Links to potentially other systems (e.g. support, user management, * Links to potentially other systems (e.g. support, user management,
* documentation etc.). * documentation etc.).
* *
*/ */
public static class Links { public static class Links {
private final Documentation documentation = new Documentation();
/**
* Link to product support.
*/
private String support = "";
/**
* Link to request a system account, access.
*/
private String requestAccount = "";
public Documentation getDocumentation() {
return documentation;
}
/** /**
* Configuration of UI documentation links. * Configuration of UI documentation links.
* *
@@ -152,111 +119,120 @@ public class UiProperties {
return deploymentView; return deploymentView;
} }
public void setDeploymentView(final String deploymentView) {
this.deploymentView = deploymentView;
}
public String getDistributionView() { public String getDistributionView() {
return distributionView; return distributionView;
} }
public void setDistributionView(final String distributionView) {
this.distributionView = distributionView;
}
public String getUploadView() {
return uploadView;
}
public void setUploadView(final String uploadView) {
this.uploadView = uploadView;
}
public String getSystemConfigurationView() {
return systemConfigurationView;
}
public void setSystemConfigurationView(final String systemConfigurationView) {
this.systemConfigurationView = systemConfigurationView;
}
public String getSecurity() {
return security;
}
public void setSecurity(final String security) {
this.security = security;
}
public String getTargetfilterView() {
return targetfilterView;
}
public void setTargetfilterView(final String targetfilterView) {
this.targetfilterView = targetfilterView;
}
public String getRolloutView() { public String getRolloutView() {
return rolloutView; return rolloutView;
} }
public void setRolloutView(final String rolloutView) {
this.rolloutView = rolloutView;
}
public String getRoot() { public String getRoot() {
return root; return root;
} }
public String getSecurity() {
return security;
}
public String getSystemConfigurationView() {
return systemConfigurationView;
}
public String getTargetfilterView() {
return targetfilterView;
}
public String getUploadView() {
return uploadView;
}
public void setDeploymentView(final String deploymentView) {
this.deploymentView = deploymentView;
}
public void setDistributionView(final String distributionView) {
this.distributionView = distributionView;
}
public void setRolloutView(final String rolloutView) {
this.rolloutView = rolloutView;
}
public void setRoot(final String root) { public void setRoot(final String root) {
this.root = root; this.root = root;
} }
public void setSecurity(final String security) {
this.security = security;
} }
public void setSystemConfigurationView(final String systemConfigurationView) {
this.systemConfigurationView = systemConfigurationView;
}
public void setTargetfilterView(final String targetfilterView) {
this.targetfilterView = targetfilterView;
}
public void setUploadView(final String uploadView) {
this.uploadView = uploadView;
}
}
private final Documentation documentation = new Documentation();
/**
* Link to product support.
*/
private String support = "";
/**
* Link to request a system account, access.
*/
private String requestAccount = "";
/** /**
* Link to user management. * Link to user management.
*/ */
private String userManagement = ""; private String userManagement = "";
public String getSupport() { public Documentation getDocumentation() {
return support; return documentation;
}
public void setSupport(final String support) {
this.support = support;
} }
public String getRequestAccount() { public String getRequestAccount() {
return requestAccount; return requestAccount;
} }
public void setRequestAccount(final String requestAccount) { public String getSupport() {
this.requestAccount = requestAccount; return support;
} }
public String getUserManagement() { public String getUserManagement() {
return userManagement; return userManagement;
} }
public void setRequestAccount(final String requestAccount) {
this.requestAccount = requestAccount;
}
public void setSupport(final String support) {
this.support = support;
}
public void setUserManagement(final String userManagement) { public void setUserManagement(final String userManagement) {
this.userManagement = userManagement; this.userManagement = userManagement;
} }
} }
/** /**
* Configuration of login view. * Configuration of login view.
* *
*/ */
public static class Login { public static class Login {
private final Cookie cookie = new Cookie();
public Cookie getCookie() {
return cookie;
}
/** /**
* Cookie configuration for login credential cookie. * Cookie configuration for login credential cookie.
* *
@@ -275,6 +251,30 @@ public class UiProperties {
this.secure = secure; this.secure = secure;
} }
} }
private final Cookie cookie = new Cookie();
public Cookie getCookie() {
return cookie;
}
}
private final Links links = new Links();
private final Login login = new Login();
private final Demo demo = new Demo();
public Demo getDemo() {
return demo;
}
public Links getLinks() {
return links;
}
public Login getLogin() {
return login;
} }
} }