diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 231324c1..fd31be20 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,3 +1,7 @@
+v3.0.1
+- Fix: Management of Keycloak's realm roles
+- Dependabot Fix: Bumped mysql-connector-java to version 8.0.28
+
v3.0.0
- New Feature: Native support of NGSI-LD Catalogues providing DCAT-AP Data models (https://github.com/smart-data-models/dataModel.DCAT-AP)
- New Feature: Integration of the functionality to map the DCAT-AP metadata of the federated catalogues in a Context Broker
diff --git a/Idra/pom.xml b/Idra/pom.xml
index 15c9d943..b33d379f 100644
--- a/Idra/pom.xml
+++ b/Idra/pom.xml
@@ -398,7 +398,7 @@
mysql
mysql-connector-java
- 8.0.16
+ 8.0.28
diff --git a/Idra/src/main/java/it/eng/idra/authentication/KeycloakAuthenticationManager.java b/Idra/src/main/java/it/eng/idra/authentication/KeycloakAuthenticationManager.java
index 8b4d62d7..a404938f 100644
--- a/Idra/src/main/java/it/eng/idra/authentication/KeycloakAuthenticationManager.java
+++ b/Idra/src/main/java/it/eng/idra/authentication/KeycloakAuthenticationManager.java
@@ -22,10 +22,13 @@
import it.eng.idra.authentication.keycloak.model.KeycloakUser;
import it.eng.idra.utils.PropertyManager;
import java.net.URI;
-import java.util.Set;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.ws.rs.core.Response;
+import org.apache.commons.collections4.CollectionUtils;
// TODO: Auto-generated Javadoc
/**
@@ -155,7 +158,18 @@ public Boolean validateToken(Object tokenObj) throws Exception {
*/
public void validateAdminRole(KeycloakUser user) throws Exception {
- Set roles = user.getRoles();
+ List roles = new ArrayList();
+
+ if (CollectionUtils.isNotEmpty(user.getRealmAccess().getRoles())) {
+ roles.addAll(user.getRealmAccess().getRoles().stream()
+ .map(x -> x.toUpperCase()).collect(Collectors.toList()));
+ }
+
+ if (CollectionUtils.isNotEmpty(user.getRoles())) {
+ roles.addAll(user.getRoles().stream()
+ .map(x -> x.toUpperCase()).collect(Collectors.toList()));
+ }
+
if (roles != null && !roles.isEmpty() && roles
.contains(PropertyManager.getProperty(IdmProperty.IDM_ADMIN_ROLE_NAME).toUpperCase())) {
// OK
diff --git a/Idra/src/main/java/it/eng/idra/authentication/keycloak/model/KeycloakUser.java b/Idra/src/main/java/it/eng/idra/authentication/keycloak/model/KeycloakUser.java
index 7f03b238..cc3270f0 100644
--- a/Idra/src/main/java/it/eng/idra/authentication/keycloak/model/KeycloakUser.java
+++ b/Idra/src/main/java/it/eng/idra/authentication/keycloak/model/KeycloakUser.java
@@ -33,6 +33,10 @@ public class KeycloakUser {
/** The roles. */
private Set roles;
+
+ /** Realm Roles. */
+ @SerializedName(value = "realm_access")
+ private RealmAccess realmAccess;
/** The name. */
private String name;
@@ -227,6 +231,25 @@ public String getEmail() {
public void setEmail(String email) {
this.email = email;
}
+
+ /**
+ * Gets the realmAccess.
+ *
+ * @return the realmAccess
+ */
+ public RealmAccess getRealmAccess() {
+ return realmAccess;
+ }
+
+ /**
+ * Sets the realmAccess.
+ *
+ * @param realmAccess the new RealmAccess
+ */
+ public void setRealmAccess(RealmAccess realmAccess) {
+ this.realmAccess = realmAccess;
+ }
+
/*
* (non-Javadoc)
@@ -240,4 +263,21 @@ public String toString() {
+ "given_name=" + givenName + ", family_name=" + familyName + ", email=" + email + "]";
}
+ /**
+ * RealmAccess class.
+ *
+ */
+ public class RealmAccess {
+ private Set roles;
+
+ public Set getRoles() {
+ return roles;
+ }
+
+ public void setRoles(Set roles) {
+ this.roles = roles;
+ }
+ }
+
+
}
diff --git a/Idra/src/main/resources/configuration.properties b/Idra/src/main/resources/configuration.properties
index 5d924c03..2c46037f 100644
--- a/Idra/src/main/resources/configuration.properties
+++ b/Idra/src/main/resources/configuration.properties
@@ -16,8 +16,8 @@
# along with this program. If not, see http://www.gnu.org/licenses/.
#-------------------------------------------------------------------------------
################# PLATFORM API ###################################
-idra.version=3.0.0
-idra.release.timestamp=2022-06-06T15:30:00Z
+idra.version=3.0.1
+idra.release.timestamp=2022-06-22T13:00:00Z
################# PERSISTENCE MANAGER CONFIGURATION ##############
#&rewriteBatchedStatements\=true