";
- html += "
" + action + "
";
-
- if (waiting) {
- html += "
";
- }
-
- html += "
" + message + "
";
- html += "
";
-
- return html;
- }
-
-}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/GeoportalServiceIdentityProxy.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/GeoportalServiceIdentityProxy.java
index 33d9ebb..b955e51 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/GeoportalServiceIdentityProxy.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/GeoportalServiceIdentityProxy.java
@@ -22,9 +22,9 @@ public class GeoportalServiceIdentityProxy {
private static final Logger LOG = LoggerFactory.getLogger(GeoportalServiceIdentityProxy.class);
private GcubeIdentity gCubeIdentity;
-
+
private boolean isUser = false;
-
+
private boolean isIAMClient = false;
/**
@@ -57,12 +57,24 @@ public class GeoportalServiceIdentityProxy {
gCubeIdentity.setIdentity(request);
}
-
+
public boolean isUser() {
return isUser;
}
-
+
public boolean isIAMClient() {
return isIAMClient;
}
+
+ public String getDescription() {
+ return gCubeIdentity.getIdentityDescription();
+ }
+
+ public String getToken() {
+ return gCubeIdentity.getToken();
+ }
+
+ public String getIdentity() {
+ return gCubeIdentity.getIdentity();
+ }
}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/GcubeIdentity.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/GcubeIdentity.java
index ad1e4e4..15e4f8c 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/GcubeIdentity.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/GcubeIdentity.java
@@ -2,16 +2,15 @@ package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessid
import javax.servlet.http.HttpServletRequest;
-
/**
* The Interface GcubeIdentity.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
- * Sep 23, 2021
+ * Sep 23, 2021
*/
public interface GcubeIdentity {
-
+
/**
* Sets the identity.
*
@@ -19,10 +18,32 @@ public interface GcubeIdentity {
* @throws Exception the exception
*/
public void setIdentity(HttpServletRequest httpRequest) throws Exception;
-
+
/**
* Reset identity.
*/
public void resetIdentity();
+ /**
+ * Gets the identity description.
+ *
+ * @return the identity description
+ */
+ public String getIdentityDescription();
+
+
+ /**
+ * Gets the identity.
+ *
+ * @return the identity
+ */
+ public String getIdentity();
+
+ /**
+ * Gets the token.
+ *
+ * @return the token
+ */
+ public String getToken();
+
}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/IAMClientIdentity.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/IAMClientIdentity.java
index 45dbc63..ca51ff2 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/IAMClientIdentity.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/IAMClientIdentity.java
@@ -16,18 +16,22 @@ public class IAMClientIdentity implements GcubeIdentity {
private static final Logger LOG = LoggerFactory.getLogger(IAMClientIdentity.class);
private String previousUMAToken = null;
+
+ private String currentUMAToken = null;
+ private String clientId = null;
+
private static final String IAM_CLIENT_CREDENTIALS = "IAM_CLIENT_CREDENTIALS";
@Override
public void setIdentity(HttpServletRequest httpRequest) throws Exception {
LOG.info("setIdentity called");
String currentScope = SessionUtil.getCurrentContext(httpRequest, true);
- IAMClientCredentials credentials = sessionGetIAMClientCredentials(httpRequest);
+ IAMClientCredentials credentials = sessionGetIAMClientCredentials(httpRequest);
try {
- if(credentials==null) {
+ if (credentials == null) {
credentials = IAMClientCredentialsReader.getCredentials();
- sessionSetIAMClientCredentials(httpRequest,credentials);
+ sessionSetIAMClientCredentials(httpRequest, credentials);
}
} catch (Exception e) {
LOG.error("Error on discovering IAM Client credentials", e);
@@ -36,7 +40,7 @@ public class IAMClientIdentity implements GcubeIdentity {
LOG.trace("Read credentials: " + credentials);
String umaAcessToken = null;
- String clientId = credentials.getClientId();
+ clientId = credentials.getClientId();
String clientSecret = credentials.getClientSecret();
try {
@@ -46,6 +50,7 @@ public class IAMClientIdentity implements GcubeIdentity {
umaAcessToken = tr.getAccessToken();
if (umaAcessToken != null && !umaAcessToken.isEmpty()) {
LOG.info("UMA Access Token read correctly");
+ currentUMAToken = umaAcessToken;
} else {
LOG.error("UMA Access Token NOT RETRIEVED!!!");
throw new Exception("UMA Access Token is null or empty");
@@ -75,6 +80,11 @@ public class IAMClientIdentity implements GcubeIdentity {
}
+ @Override
+ public String getToken() {
+ return currentUMAToken;
+ }
+
@Override
public void resetIdentity() {
LOG.info("resetIdentity called");
@@ -82,7 +92,7 @@ public class IAMClientIdentity implements GcubeIdentity {
LOG.info("resetIdentity to previous AccessToken");
}
-
+
/**
* Gets the IAM client credentials.
*
@@ -103,7 +113,7 @@ public class IAMClientIdentity implements GcubeIdentity {
* Sets the IAM client credentials.
*
* @param httpRequest the http request
- * @param iamCC the iam CC
+ * @param iamCC the iam CC
*/
public static void sessionSetIAMClientCredentials(HttpServletRequest httpRequest, IAMClientCredentials iamCC) {
HttpSession session = httpRequest.getSession();
@@ -114,4 +124,15 @@ public class IAMClientIdentity implements GcubeIdentity {
}
}
+ @Override
+ public String getIdentityDescription() {
+ return "ClientId: "+ clientId;
+
+ }
+
+ @Override
+ public String getIdentity() {
+ return clientId;
+ }
+
}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/UserIdentity.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/UserIdentity.java
index f2ee8f9..3a6f79f 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/UserIdentity.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/UserIdentity.java
@@ -3,6 +3,7 @@ package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessid
import javax.servlet.http.HttpServletRequest;
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
+import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -10,13 +11,19 @@ public class UserIdentity implements GcubeIdentity {
private static final Logger LOG = LoggerFactory.getLogger(UserIdentity.class);
+ private HttpServletRequest httpRequest;
+
+ private GCubeUser user;
+
public UserIdentity() {
}
@Override
public void setIdentity(HttpServletRequest httpRequest) throws Exception {
LOG.info("setIdentity called");
+ this.httpRequest = httpRequest;
SessionUtil.getCurrentToken(httpRequest, true);
+ user = SessionUtil.getCurrentUser(httpRequest);
}
@@ -25,4 +32,20 @@ public class UserIdentity implements GcubeIdentity {
LOG.info("resetIdentity called, doing nothing");
// doing nothing
}
+
+ @Override
+ public String getToken() {
+ return SessionUtil.getCurrentToken(httpRequest, true);
+ }
+
+ @Override
+ public String getIdentityDescription() {
+ return user != null ? "user: " + user.getUsername() : "null";
+ }
+
+ @Override
+ public String getIdentity() {
+ return user.getUsername();
+ }
+
}
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index 81b416b..70095f1 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -16,11 +16,16 @@