diff --git a/admin-tools-core/src/main/java/de/chandre/admintool/core/component/AdminComponent.java b/admin-tools-core/src/main/java/de/chandre/admintool/core/component/AdminComponent.java
index 7045e1f..bc5c224 100644
--- a/admin-tools-core/src/main/java/de/chandre/admintool/core/component/AdminComponent.java
+++ b/admin-tools-core/src/main/java/de/chandre/admintool/core/component/AdminComponent.java
@@ -1,142 +1,146 @@
-package de.chandre.admintool.core.component;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A admin component
- * should have at least a minimum of one menu entry
- * @author Andre
- *
- */
-public interface AdminComponent extends Comparable
-{
- /**
- * @return the displayName
- */
- String getDisplayName();
-
- /**
- * @param displayName the displayName to set
- */
- void setDisplayName(String displayName);
-
- /**
- * @return the mainMenu
- */
- MenuEntry getMainMenu();
-
- /**
- * @param mainMenu the mainMenu to set
- */
- void setMainMenu(MenuEntry mainMenu);
-
- /**
- * @return the notificationTemplates
- */
- List getNotificationTemplates();
-
- /**
- * path to notification template shown in the top right menu
- * should start with a "li" tag. eg:
- *
- * <li class="dropdown messages-menu">
- *
- * @see https://almsaeedstudio.com/themes/AdminLTE/documentation/index.html#component-main-header
- *
- * @param notificationTemplates the notificationTemplates to set
- */
- void setNotificationTemplates(List notificationTemplates);
-
- /**
- * path to notification template shown in the top right menu
- * should start with a "li" tag. eg:
- *
- * <li class="dropdown messages-menu">
- *
- * @see https://almsaeedstudio.com/themes/AdminLTE/documentation/index.html#component-main-header
- *
- * @param notificationTemplate the template path to notification template
- */
- void addNotificationTemplate(String notificationTemplate);
-
- /**
- * @return the additionalCSS
- */
- Map getAdditionalCSS();
-
- /**
- * map with paths to CSS.
- *
- * @param additionalCSS the additionalCSS to set
- * @see #addAdditionalCSS(String, boolean)
- */
- void setAdditionalCSS(Map additionalCSS);
-
- /**
- * path to CSS.
- * Example:
- *
- * addAdditionalCSS("/static/myComponent/css/myStyles.css", true);
- * addAdditionalCSS("http://example.com/styles.css", false);
- *
- * @param additionalCSS the additionalCSS to set
- */
- void addAdditionalCSS(String additionalCSS, boolean relative);
-
- /**
- * @return the additionalJS
- */
- Map getAdditionalJS();
-
- /**
- * map with path to additional JavaScript files.
- * @param additionalJS the additionalJS to set
- * @see #addAdditionalJS(String, boolean)
- */
- void setAdditionalJS(Map additionalJS);
-
- /**
- * path to additional JavaScript files.
- * Example:
- *
- * addAdditionalJS("/static/myComponent/js/myScripts.js", true);
- * addAdditionalJS("http://example.com/script.js", false);
- *
- * @param additionalJS the additionalJS to set
- */
- void addAdditionalJS(String additionalJS, boolean relative);
-
- /**
- * should return a list of roles which should be able to access this component
- * @return
- * @since 1.0.1
- */
- Set getSecurityRoles();
-
- /**
- * security role like "ROLE_USER" or for anonymous "ROLE_ANONYMOUS" validated with spring security
- * requires: admin-tool-core-security
- * setting these roles will no effect on access, only for displaying or hiding menu entries
- * the access restrictions must be done by your own with the security configuration
- *
- * @param securityRole
- * @since 1.0.1
- */
- void addSecurityRole(String securityRole);
-
- /**
- * position of component in menu. Initially set to {@link Integer#MAX_VALUE}
- * @return
- * @since 1.0.1
- */
- Integer getPosition();
-
- /**
- * position of component in menu. Initially set to {@link Integer#MAX_VALUE}
- * @param position
- * @since 1.0.1
- */
- void setPosition(Integer position);
-}
+package de.chandre.admintool.core.component;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A admin component
+ * should have at least a minimum of one menu entry
+ * @author Andre
+ *
+ */
+public interface AdminComponent extends Comparable
+{
+ /**
+ * @return the displayName
+ */
+ String getDisplayName();
+
+ /**
+ * @param displayName the displayName to set
+ */
+ void setDisplayName(String displayName);
+
+ /**
+ * @return the mainMenu
+ */
+ MenuEntry getMainMenu();
+
+ /**
+ * @param mainMenu the mainMenu to set
+ */
+ void setMainMenu(MenuEntry mainMenu);
+
+ /**
+ * @return the notificationTemplates
+ */
+ List getNotificationTemplates();
+
+ /**
+ * path to notification template shown in the top right menu
+ * should start with a "li" tag. eg:
+ *
+ * <li class="dropdown messages-menu">
+ *
+ * @see https://almsaeedstudio.com/themes/AdminLTE/documentation/index.html#component-main-header
+ *
+ * @param notificationTemplates the notificationTemplates to set
+ */
+ void setNotificationTemplates(List notificationTemplates);
+
+ /**
+ * path to notification template shown in the top right menu
+ * should start with a "li" tag. eg:
+ *
+ * <li class="dropdown messages-menu">
+ *
+ * @see https://almsaeedstudio.com/themes/AdminLTE/documentation/index.html#component-main-header
+ *
+ * @param notificationTemplate the template path to notification template
+ */
+ void addNotificationTemplate(String notificationTemplate);
+
+ /**
+ * @return the additionalCSS
+ */
+ Map getAdditionalCSS();
+
+ /**
+ * map with paths to CSS.
+ *
+ * @param additionalCSS the additionalCSS to set
+ * @see #addAdditionalCSS(String, boolean)
+ */
+ void setAdditionalCSS(Map additionalCSS);
+
+ /**
+ * path to CSS.
+ * Example:
+ *
+ * addAdditionalCSS("/static/myComponent/css/myStyles.css", true);
+ * addAdditionalCSS("http://example.com/styles.css", false);
+ *
+ * @param additionalCSS the additionalCSS to set
+ */
+ void addAdditionalCSS(String additionalCSS, boolean relative);
+
+ /**
+ * @return the additionalJS
+ */
+ Map getAdditionalJS();
+
+ /**
+ * map with path to additional JavaScript files.
+ * @param additionalJS the additionalJS to set
+ * @see #addAdditionalJS(String, boolean)
+ */
+ void setAdditionalJS(Map additionalJS);
+
+ /**
+ * path to additional JavaScript files.
+ * Example:
+ *
+ * addAdditionalJS("/static/myComponent/js/myScripts.js", true);
+ * addAdditionalJS("http://example.com/script.js", false);
+ *
+ * @param additionalJS the additionalJS to set
+ */
+ void addAdditionalJS(String additionalJS, boolean relative);
+
+ /**
+ * should return a list of roles which should be able to access this component
+ * @return
+ * @since 1.0.1
+ * @deprecated unnecessary because url resolving in template will work, will be removed with version 1.2.0
+ */
+ @Deprecated
+ Set getSecurityRoles();
+
+ /**
+ * security role like "ROLE_USER" or for anonymous "ROLE_ANONYMOUS" validated with spring security
+ * requires: admin-tool-core-security
+ * setting these roles will no effect on access, only for displaying or hiding menu entries
+ * the access restrictions must be done by your own with the security configuration
+ *
+ * @param securityRole
+ * @since 1.0.1
+ * @deprecated unnecessary because url resolving in template will work, will be removed with version 1.2.0
+ */
+ @Deprecated
+ void addSecurityRole(String securityRole);
+
+ /**
+ * position of component in menu. Initially set to {@link Integer#MAX_VALUE}
+ * @return
+ * @since 1.0.1
+ */
+ Integer getPosition();
+
+ /**
+ * position of component in menu. Initially set to {@link Integer#MAX_VALUE}
+ * @param position
+ * @since 1.0.1
+ */
+ void setPosition(Integer position);
+}
diff --git a/admin-tools-core/src/main/java/de/chandre/admintool/core/component/AdminComponentImpl.java b/admin-tools-core/src/main/java/de/chandre/admintool/core/component/AdminComponentImpl.java
index ab2ca9d..87edaca 100644
--- a/admin-tools-core/src/main/java/de/chandre/admintool/core/component/AdminComponentImpl.java
+++ b/admin-tools-core/src/main/java/de/chandre/admintool/core/component/AdminComponentImpl.java
@@ -25,6 +25,7 @@ public class AdminComponentImpl implements AdminComponent
private Map additionalCSS = new LinkedHashMap<>(1);
private Map additionalJS = new LinkedHashMap<>(1);
+ @Deprecated
private Set securityRoles = new HashSet<>();
private Integer position;
@@ -169,8 +170,10 @@ public void addAdditionalJS(String additionalJS, boolean relative) {
* @since 1.0.1
* @return the securityRoles
* @see #addSecurityRole(String)
+ * @deprecated unnecessary because url resolving in template will work, will be removed with version 1.2.0
*/
@Override
+ @Deprecated
public Set getSecurityRoles() {
return securityRoles;
}
@@ -180,12 +183,15 @@ public Set getSecurityRoles() {
* @since 1.0.1
* @param securityRoles the securityRoles to set
* @see #addSecurityRole(String)
+ * @deprecated unnecessary because url resolving in template will work, will be removed with version 1.2.0
*/
+ @Deprecated
public void setSecurityRoles(Set securityRoles) {
this.securityRoles = securityRoles;
}
@Override
+ @Deprecated
public void addSecurityRole(String securityRole) {
this.securityRoles.add(securityRole);
}
@@ -380,8 +386,10 @@ public AdminComponentBuilder additionalJS(String additionalJS, boolean relative)
/**
* @see AdminComponent#addSecurityRole(String)
* @param securityRole
+ * @deprecated unnecessary because url resolving in template will work, will be removed with version 1.2.0
* @return
*/
+ @Deprecated
public AdminComponentBuilder securityRole(String securityRole) {
component.addSecurityRole(securityRole);
return this;
@@ -389,8 +397,10 @@ public AdminComponentBuilder securityRole(String securityRole) {
/**
* @see AdminComponent#getSecurityRoles().addAll(set)
* @param securityRoles
+ * @deprecated unnecessary because url resolving in template will work, will be removed with version 1.2.0
* @return
*/
+ @Deprecated
public AdminComponentBuilder securityRoles(Set securityRoles) {
component.getSecurityRoles().addAll(securityRoles);
return this;
diff --git a/admin-tools-core/src/main/java/de/chandre/admintool/core/component/MenuEntry.java b/admin-tools-core/src/main/java/de/chandre/admintool/core/component/MenuEntry.java
index dc5f8f4..42742ea 100644
--- a/admin-tools-core/src/main/java/de/chandre/admintool/core/component/MenuEntry.java
+++ b/admin-tools-core/src/main/java/de/chandre/admintool/core/component/MenuEntry.java
@@ -44,6 +44,7 @@ public class MenuEntry implements Serializable
private boolean useJSHierarchy = false;
private Map additionalJS = new LinkedHashMap<>(1);
+ @Deprecated
private Set securityRoles = new HashSet<>();
private Map variables = new HashMap<>();
@@ -74,6 +75,7 @@ public MenuEntry(String name, String displayName, String target) {
* @param target - the template path. see {@link #setTarget(String)}
* @param securityRoles - Set of roles to check against the current user for displaying/hiding menu entries in the frontend
*/
+ @Deprecated
public MenuEntry(String name, String displayName, String target, Set securityRoles) {
super();
this.name = name;
@@ -410,7 +412,9 @@ public void setUseJSHierarchy(boolean useJSHierarchy) {
* first menu entry or component with roles will return it.
* @return a unmodifiable Set or empty Set
* @since 1.0.1
+ * @deprecated unnecessary because url resolving in template will work, will be removed with version 1.2.0
*/
+ @Deprecated
public Set getAffectedSecurityRoles() {
if (CollectionUtils.isEmpty(securityRoles)) {
Stream parents = reverseFlattened();
@@ -435,7 +439,9 @@ public Set getAffectedSecurityRoles() {
/**
* @return the securityRoles
* @since 1.0.1
+ * @deprecated unnecessary because url resolving in template will work, will be removed with version 1.2.0
*/
+ @Deprecated
public Set getSecurityRoles() {
return securityRoles;
}
@@ -443,7 +449,9 @@ public Set getSecurityRoles() {
/**
* @param securityRoles the securityRoles to set
* @since 1.0.1
+ * @deprecated unnecessary because url resolving in template will work, will be removed with version 1.2.0
*/
+ @Deprecated
public void setSecurityRoles(Set securityRoles) {
this.securityRoles = securityRoles;
}
@@ -451,7 +459,9 @@ public void setSecurityRoles(Set securityRoles) {
/**
* @param securityRole the securityRoles to set
* @since 1.0.1
+ * @deprecated unnecessary because url resolving in template will work, will be removed with version 1.2.0
*/
+ @Deprecated
public void addSecurityRole(String securityRole) {
this.securityRoles.add(securityRole);
}
@@ -749,7 +759,9 @@ public MenuEntryBuilder useJSHierarchy(boolean useJSHierarchy) {
* @see MenuEntry#setSecurityRoles(Set)
* @param securityRoles
* @return
+ * @deprecated unnecessary because url resolving in template will work, will be removed with version 1.2.0
*/
+ @Deprecated
public MenuEntryBuilder securityRoles(Set securityRoles) {
entry.setSecurityRoles(securityRoles);
return this;
@@ -758,7 +770,9 @@ public MenuEntryBuilder securityRoles(Set securityRoles) {
* @see MenuEntry#addSecurityRole(String)
* @param securityRole
* @return
+ * @deprecated unnecessary because url resolving in template will work, will be removed with version 1.2.0
*/
+ @Deprecated
public MenuEntryBuilder securityRole(String securityRole) {
entry.addSecurityRole(securityRole);
return this;
diff --git a/admin-tools-core/src/main/resources/static/admintool/js/select2-util.js b/admin-tools-core/src/main/resources/static/admintool/js/select2-util.js
index cd7c30e..d4e71c2 100644
--- a/admin-tools-core/src/main/resources/static/admintool/js/select2-util.js
+++ b/admin-tools-core/src/main/resources/static/admintool/js/select2-util.js
@@ -26,7 +26,7 @@ AdminTool.Select2Util = function(parent) {
};
this.clearSelect = function(selectId) {
-// self.setValue(selectId);
+ self.setValue(selectId);
};
this.setValue = function(selectId, value = []) {
@@ -83,4 +83,4 @@ AdminTool.Select2Util = function(parent) {
};
this.construct(parent);
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/admin-tools-core/src/main/resources/static/admintool/js/validation-util.js b/admin-tools-core/src/main/resources/static/admintool/js/validation-util.js
index 38576cf..78ea2e1 100644
--- a/admin-tools-core/src/main/resources/static/admintool/js/validation-util.js
+++ b/admin-tools-core/src/main/resources/static/admintool/js/validation-util.js
@@ -11,6 +11,10 @@ AdminTool.ValidationUtil = function(parent) {
return getByID(formId).validator();
};
+ this.destroy = function(formId) {
+ getByID(formId).validator('destroy');
+ };
+
this.validate = function(formId) {
getByID(formId).validator('validate');
return self.hasValidationErrors(formId);
@@ -27,19 +31,19 @@ AdminTool.ValidationUtil = function(parent) {
};
this.reloadValidator = function(formId) {
- getByID(formId).validator('destroy');
+ self.destroy(formId);
// validator doesn't remove everything
getByID(formId).find('.form-control-feedback').removeClass(
'glyphicon-remove');
self.create(formId);
};
- this.showFieldErrorsOnATErrorList = function(data) {
+ this.showFieldErrorsOnATErrorList = function(data, formId) {
var globalErrors = [];
for (var i = 0; i < data.length; i++) {
var error = data[i];
if (error.field && error.field.length > 0) {
- self.parent.showCustomError(error.field, error.message, this.userDataFormId);
+ self.showCustomError(error.field, error.message, formId);
} else {
globalErrors.push('
' + error.message + '
');
}
@@ -51,4 +55,4 @@ AdminTool.ValidationUtil = function(parent) {
};
this.construct(parent);
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/admin-tools-security/admin-tools-security-commons/src/main/java/de/chandre/admintool/security/commons/auth/LoginAttemptServiceImpl.java b/admin-tools-security/admin-tools-security-commons/src/main/java/de/chandre/admintool/security/commons/auth/LoginAttemptServiceImpl.java
index 0d0c57f..77c8126 100644
--- a/admin-tools-security/admin-tools-security-commons/src/main/java/de/chandre/admintool/security/commons/auth/LoginAttemptServiceImpl.java
+++ b/admin-tools-security/admin-tools-security-commons/src/main/java/de/chandre/admintool/security/commons/auth/LoginAttemptServiceImpl.java
@@ -25,14 +25,33 @@ public class LoginAttemptServiceImpl implements LoginAttemptService {
private final Map attemptsCache = new ConcurrentHashMap<>();
+ /**
+ * initializes the LoginAttemptService with maxAttempts=5, useUserName=true and useRemoteAddress=false
+ *
+ * @see #LoginAttemptServiceImpl(int, boolean, boolean)
+ */
public LoginAttemptServiceImpl() {
this(5);
}
+ /**
+ * initializes the LoginAttemptService with given maxAttempt, useUserName=true and useRemoteAddress=false
+ *
+ * @param maxAttempts number of maximum attempts a user can try logging in with wrong password until service marks user as blocked
+ *
+ * @see #LoginAttemptServiceImpl(int, boolean, boolean)
+ */
public LoginAttemptServiceImpl(int maxAttempts) {
this(maxAttempts, true, false);
}
+ /**
+ * initializes the LoginAttemptService with given parameters
+ *
+ * @param maxAttempts number of maximum attempts a user can try logging in with wrong password until service marks user as blocked
+ * @param useUserName used in login failure/success listeners to add user/invalidate username
+ * @param useRemoteAddress used in login failure/success listeners to add user/invalidate remote address (may not work/be used when behind a (reverse)proxy)
+ */
public LoginAttemptServiceImpl(int maxAttempts, boolean useUserName, boolean useRemoteAddress) {
super();
MAX_ATTEMPT = maxAttempts;
diff --git a/admin-tools-security/admin-tools-security-commons/src/main/resources/templates/admintool/layout/anonymousLayout.html b/admin-tools-security/admin-tools-security-commons/src/main/resources/templates/admintool/layout/anonymousLayout.html
new file mode 100644
index 0000000..2b5644d
--- /dev/null
+++ b/admin-tools-security/admin-tools-security-commons/src/main/resources/templates/admintool/layout/anonymousLayout.html
@@ -0,0 +1,119 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin-tools-security/admin-tools-security-commons/src/main/resources/templates/admintool/login.html b/admin-tools-security/admin-tools-security-commons/src/main/resources/templates/admintool/login.html
index 3c4d899..ee3e9ed 100644
--- a/admin-tools-security/admin-tools-security-commons/src/main/resources/templates/admintool/login.html
+++ b/admin-tools-security/admin-tools-security-commons/src/main/resources/templates/admintool/login.html
@@ -1,122 +1,46 @@
-
-
-
-
-
-
-
-
-
-
-
-