reverted to previous oidc-library-portal (1.3.0-SNAPSHOT) as requested
at #21346#note-19
This commit is contained in:
parent
64ae1604c6
commit
e5ff5c2f24
|
@ -9,7 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||||
#### Enhancements
|
#### Enhancements
|
||||||
|
|
||||||
[#21379] Moved to new ws-synchronized-module-library (based on w-thredds 1.x) and performed UMA tokens "context switches"
|
[#21379] Moved to new ws-synchronized-module-library (based on w-thredds 1.x) and performed UMA tokens "context switches"
|
||||||
[#21444] Moved to maven-portal-bom >= 3.6.2-SNAPSHOT
|
[#21444] Moved to maven-portal-bom 3.6.2
|
||||||
|
|
||||||
## [v1.3.0] - 2021-03-17
|
## [v1.3.0] - 2021-03-17
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,11 @@ import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
|
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
|
import org.gcube.common.authorization.library.provider.UmaJWTProvider;
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.oidc.rest.JWTToken;
|
import org.gcube.oidc.rest.JWTToken;
|
||||||
import org.gcube.portal.oidc.lr62.JWTTokenUtil;
|
|
||||||
import org.gcube.portal.oidc.lr62.OIDCUmaUtil;
|
import org.gcube.portal.oidc.lr62.OIDCUmaUtil;
|
||||||
import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
|
import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
|
||||||
import org.gcube.portal.wssynclibrary.shared.WorkspaceFolderLocked;
|
import org.gcube.portal.wssynclibrary.shared.WorkspaceFolderLocked;
|
||||||
|
@ -29,6 +28,7 @@ import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class SyncronizeWithThredds.
|
* The Class SyncronizeWithThredds.
|
||||||
*
|
*
|
||||||
|
@ -84,31 +84,40 @@ public class SyncronizeWithThredds {
|
||||||
logger.debug("Setting UMA context with target scope: " + targetScope + ", user: " + user.getUsername());
|
logger.debug("Setting UMA context with target scope: " + targetScope + ", user: " + user.getUsername());
|
||||||
String previousUMAToken = null;
|
String previousUMAToken = null;
|
||||||
try {
|
try {
|
||||||
previousUMAToken = AccessTokenProvider.instance.get();
|
previousUMAToken = UmaJWTProvider.instance.get();
|
||||||
JWTToken umaToken = OIDCUmaUtil.getUMAToken(httpRequest, user.getUsername(), targetScope);
|
JWTToken umaToken = OIDCUmaUtil.getUMAToken(httpRequest, user.getUsername(), targetScope);
|
||||||
|
setContextForUMA(umaToken.getRaw());
|
||||||
if (umaToken == null) {
|
|
||||||
logger.info("Uma Token is null or empty, skipping operation and returning null");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String subAccessToken = umaToken.getAccessTokenString().substring(0, 10);
|
|
||||||
logger.info("Going to set UMA Token: " + subAccessToken+ "-MASKED-TOKEN");
|
|
||||||
// UmaJWTProvider.instance.set(umaToken);
|
|
||||||
AccessTokenProvider.instance.set(JWTTokenUtil.getAccessTokenString(umaToken));
|
|
||||||
logger.debug("UmaJWTProvider instance set performed to : " + subAccessToken+ "-MASKED-TOKEN");
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("Error on set context for UMA: ", e);
|
logger.warn("Error on set context for UMA: ", e);
|
||||||
if (previousUMAToken != null) {
|
if (previousUMAToken != null) {
|
||||||
logger.info("Setting previous UMA Token: " + previousUMAToken.substring(0, 10) + "-MASKED-TOKEN");
|
logger.info("Setting previous UMA Token: " + previousUMAToken.substring(0, 10) + "-MASKED-TOKEN");
|
||||||
AccessTokenProvider.instance.set(previousUMAToken);
|
setContextForUMA(previousUMAToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return previousUMAToken;
|
return previousUMAToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset context for UMA.
|
||||||
|
*
|
||||||
|
* @param umaToken the uma token
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
private void setContextForUMA(String umaToken) {
|
||||||
|
logger.info("called set context for UMA");
|
||||||
|
|
||||||
|
if (umaToken == null || umaToken.isEmpty()) {
|
||||||
|
logger.info("Uma Token is null or empty, skipping operation");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info("Going to set UMA Token: " + umaToken.substring(0, 10) + "-MASKED-TOKEN");
|
||||||
|
UmaJWTProvider.instance.set(umaToken);
|
||||||
|
logger.debug("UmaJWTProvider instance set performed to : " + umaToken.substring(0, 10) + "-MASKED-TOKEN");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is item synched.
|
* Checks if is item synched.
|
||||||
*
|
*
|
||||||
|
@ -132,9 +141,9 @@ public class SyncronizeWithThredds {
|
||||||
* Gets the configuration.
|
* Gets the configuration.
|
||||||
*
|
*
|
||||||
* @param folderId the folder id
|
* @param folderId the folder id
|
||||||
* @param loadStatus the load status. If true it loads the status by calling
|
* @param loadStatus the load status. If true it loads the status by calling the
|
||||||
* the {@link SyncEngine#check(String, boolean)} but it is
|
* {@link SyncEngine#check(String, boolean)} but it is time
|
||||||
* time consuming. Otherwise it calls the
|
* consuming. Otherwise it calls the
|
||||||
* {@link SyncEngine#getConfig(String)} without sync status
|
* {@link SyncEngine#getConfig(String)} without sync status
|
||||||
* @param httpRequest the http request
|
* @param httpRequest the http request
|
||||||
* @param user the user
|
* @param user the user
|
||||||
|
@ -142,8 +151,8 @@ public class SyncronizeWithThredds {
|
||||||
* @throws ItemNotSynched the item not synched
|
* @throws ItemNotSynched the item not synched
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public ThSyncFolderDescriptor getConfiguration(String folderId, boolean loadStatus, HttpServletRequest httpRequest,
|
public ThSyncFolderDescriptor getConfiguration(String folderId, boolean loadStatus, HttpServletRequest httpRequest, GCubeUser user)
|
||||||
GCubeUser user) throws ItemNotSynched, Exception {
|
throws ItemNotSynched, Exception {
|
||||||
|
|
||||||
ThSyncFolderDescriptor config = null;
|
ThSyncFolderDescriptor config = null;
|
||||||
String wsScope = PortalContext.getConfiguration().getCurrentScope(httpRequest);
|
String wsScope = PortalContext.getConfiguration().getCurrentScope(httpRequest);
|
||||||
|
@ -178,19 +187,18 @@ public class SyncronizeWithThredds {
|
||||||
logger.debug("WorkspaceNotSynchedException catched. The item with id: " + folderId + " is not synched");
|
logger.debug("WorkspaceNotSynchedException catched. The item with id: " + folderId + " is not synched");
|
||||||
} catch (WorkspaceFolderLocked e1) {
|
} catch (WorkspaceFolderLocked e1) {
|
||||||
logger.info("The folder with id: " + folderId + " is locked");
|
logger.info("The folder with id: " + folderId + " is locked");
|
||||||
throw new Exception(
|
throw new Exception("The folder with id: "+folderId +" is currently locked. Another sync process is in progress");
|
||||||
"The folder with id: " + folderId + " is currently locked. Another sync process is in progress");
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error on reading the configuration for id: " + folderId, e);
|
logger.error("Error on reading the configuration for id: " + folderId, e);
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
if (previousUmaToken != null) {
|
if(previousUmaToken!=null) {
|
||||||
// resetting UMA token in the WS scope
|
// resetting UMA token in the WS scope
|
||||||
AccessTokenProvider.instance.set(previousUmaToken);
|
setContextForUMA(previousUmaToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (originalScope != null && targetScope != null && originalScope.compareTo(targetScope) != 0) {
|
if (originalScope != null && targetScope!=null && originalScope.compareTo(targetScope) != 0) {
|
||||||
logger.info("Resetting the scope: " + originalScope + " which was original WS context");
|
logger.info("Resetting the scope: " + originalScope + " which was original WS context");
|
||||||
ScopeProvider.instance.set(originalScope);
|
ScopeProvider.instance.set(originalScope);
|
||||||
if (originalToken != null) {
|
if (originalToken != null) {
|
||||||
|
@ -242,10 +250,8 @@ public class SyncronizeWithThredds {
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
if (previousUmaToken != null) {
|
|
||||||
// resetting UMA token in the WS scope
|
// resetting UMA token in the WS scope
|
||||||
AccessTokenProvider.instance.set(previousUmaToken);
|
setContextForUMA(previousUmaToken);
|
||||||
}
|
|
||||||
|
|
||||||
if (originalScope != null && originalScope.compareTo(targetScope) != 0) {
|
if (originalScope != null && originalScope.compareTo(targetScope) != 0) {
|
||||||
logger.info("Resetting the scope: " + originalScope + " which was original WS context");
|
logger.info("Resetting the scope: " + originalScope + " which was original WS context");
|
||||||
|
@ -326,15 +332,13 @@ public class SyncronizeWithThredds {
|
||||||
return workspaceThreddsSynchronizeLib.doSync(folderId);
|
return workspaceThreddsSynchronizeLib.doSync(folderId);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error on doSyncFolder for folderId: " + folderId, e);
|
logger.error("Error on doSyncFolder for folderId: "+folderId, e);
|
||||||
throw e;
|
throw e;
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
if (previousUmaToken != null) {
|
|
||||||
// resetting UMA token in the WS scope
|
// resetting UMA token in the WS scope
|
||||||
AccessTokenProvider.instance.set(previousUmaToken);
|
setContextForUMA(previousUmaToken);
|
||||||
}
|
|
||||||
|
|
||||||
if (originalScope != null && originalScope.compareTo(targetScope) != 0) {
|
if (originalScope != null && originalScope.compareTo(targetScope) != 0) {
|
||||||
logger.info("Resetting the scope: " + originalScope + " which was original WS context");
|
logger.info("Resetting the scope: " + originalScope + " which was original WS context");
|
||||||
|
@ -404,10 +408,8 @@ public class SyncronizeWithThredds {
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
if (previousUmaToken != null) {
|
|
||||||
// resetting UMA token in the WS scope
|
// resetting UMA token in the WS scope
|
||||||
AccessTokenProvider.instance.set(previousUmaToken);
|
setContextForUMA(previousUmaToken);
|
||||||
}
|
|
||||||
|
|
||||||
if (originalScope != null && originalScope.compareTo(targetScope) != 0) {
|
if (originalScope != null && originalScope.compareTo(targetScope) != 0) {
|
||||||
logger.info("Resetting the scope: " + originalScope + " which was original WS context");
|
logger.info("Resetting the scope: " + originalScope + " which was original WS context");
|
||||||
|
|
Loading…
Reference in New Issue