add check on preproduction infra if dev infra is used. See 24149
This commit is contained in:
parent
66cf4e3ab1
commit
d09f7f4d78
41
.classpath
41
.classpath
|
@ -1,10 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/target/
|
|
@ -41,11 +41,12 @@ public class UserAccountingConsumer extends Thread{
|
|||
private String clientId;
|
||||
private String secret;
|
||||
private String oidcEndpoint;
|
||||
private String oidcEndpointPreprod;
|
||||
String[] server;
|
||||
List<String> dtsHosts;
|
||||
// private String id;
|
||||
|
||||
public UserAccountingConsumer(String[] srvs, CubbyHole c, int number,List<String> dtsHosts, String clientId, String secret, String authEndpoint){
|
||||
public UserAccountingConsumer(String[] srvs, CubbyHole c, int number,List<String> dtsHosts, String clientId, String secret, String authEndpoint, String preprodAuthEndpoint){
|
||||
this.c=c;
|
||||
this.number=number;
|
||||
this.server=srvs;
|
||||
|
@ -53,6 +54,7 @@ public class UserAccountingConsumer extends Thread{
|
|||
this.clientId=clientId;
|
||||
this.secret=secret;
|
||||
this.oidcEndpoint=authEndpoint;
|
||||
this.oidcEndpointPreprod=preprodAuthEndpoint;
|
||||
// init the accounting report
|
||||
try {
|
||||
init();
|
||||
|
@ -61,7 +63,7 @@ public class UserAccountingConsumer extends Thread{
|
|||
}
|
||||
}
|
||||
|
||||
public UserAccountingConsumer(String[] srvs, String user, String password, CubbyHole c, int number, List<String> dtsHosts, String clientId, String secret, String authEndpoint){
|
||||
public UserAccountingConsumer(String[] srvs, String user, String password, CubbyHole c, int number, List<String> dtsHosts, String clientId, String secret, String authEndpoint, String preprodAuthEndpoint){
|
||||
this.c=c;
|
||||
this.number=number;
|
||||
this.server=srvs;
|
||||
|
@ -71,7 +73,7 @@ public class UserAccountingConsumer extends Thread{
|
|||
this.clientId=clientId;
|
||||
this.secret=secret;
|
||||
this.oidcEndpoint=authEndpoint;
|
||||
|
||||
this.oidcEndpointPreprod=preprodAuthEndpoint;
|
||||
// init the accounting report
|
||||
try {
|
||||
init();
|
||||
|
@ -255,7 +257,16 @@ public class UserAccountingConsumer extends Thread{
|
|||
logger.trace("preparing URL");
|
||||
oidcAddress = new URL(oidcEndpoint);
|
||||
logger.trace("URL ready: "+oidcAddress);
|
||||
Utils.setToken(oidcAddress, clientId, secret);
|
||||
try{
|
||||
Utils.setToken(oidcAddress, clientId, secret);
|
||||
}catch(Exception e){
|
||||
logger.error("problem retrieving token. "+e.getMessage());
|
||||
if (oidcEndpointPreprod != null){
|
||||
logger.info("Try to sent to preproduction infrastructure: "+oidcEndpointPreprod);
|
||||
URL oidcPreproductionAddress= = new URL(oidcEndpointPreprod);
|
||||
Utils.setToken(oidcPreproductionAddress, clientId, secret);
|
||||
}
|
||||
}
|
||||
logger.trace("token ready");
|
||||
} catch (MalformedURLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.scope.impl.ScopeProviderScanner;
|
||||
import org.gcube.contentmanager.storageserver.consumer.FolderAccountingConsumer;
|
||||
import org.gcube.contentmanager.storageserver.consumer.UserAccountingConsumer;
|
||||
import org.gcube.contentmanager.storageserver.data.CubbyHole;
|
||||
|
@ -21,7 +22,9 @@ public class Startup {
|
|||
private static String clientId;
|
||||
private static String secret;
|
||||
private static String oidcEndpoint;
|
||||
|
||||
//used only in dev/preproduction enviroment bug 24149
|
||||
private static String oidcPreproductionEndpoint;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
for (int i=0; i<args.length;i++)
|
||||
|
@ -59,6 +62,16 @@ public class Startup {
|
|||
clientId=cfg.getClientId();
|
||||
secret=cfg.getSecret();
|
||||
oidcEndpoint=cfg.getOidcEndpoint();
|
||||
/** PATCH 24149 related to dev, preprod only **/
|
||||
if (scope.equals("/gcube")){
|
||||
String currentScope=ScopeProvider.instance.get();
|
||||
//set hardcoded preproduction scope temporarily
|
||||
ScopeProvider.instance.set("/pred4s");
|
||||
oidcPreproductionEndpoint=cfg.getOidcEndpoint();
|
||||
ScopeProvider.instance.set(currentScope);
|
||||
}
|
||||
|
||||
/** end PATCH**/
|
||||
String[] server=retrieveServerConfiguration(cfg);
|
||||
|
||||
List<String> dtsHosts=null;//retrieveDTSConfiguration(cfg);
|
||||
|
@ -84,10 +97,10 @@ public class Startup {
|
|||
String[] server, List<String> dtsHosts, CubbyHole c1) {
|
||||
UserAccountingConsumer ssConsumer=null;
|
||||
if(user!=null && password != null)
|
||||
ssConsumer=new UserAccountingConsumer(server, user, password, c1, 1, dtsHosts, clientId, secret, oidcEndpoint);
|
||||
ssConsumer=new UserAccountingConsumer(server, user, password, c1, 1, dtsHosts, clientId, secret, oidcEndpoint, oidcPreproductionEndpoint);
|
||||
|
||||
else //if(args.length == 4)
|
||||
ssConsumer=new UserAccountingConsumer(server, c1, 1, dtsHosts, clientId, secret, oidcEndpoint);
|
||||
ssConsumer=new UserAccountingConsumer(server, c1, 1, dtsHosts, clientId, secret, oidcEndpoint, oidcPreproductionEndpoint);
|
||||
// else{
|
||||
// throw new IllegalArgumentException("input parameter are incorrect");
|
||||
// }
|
||||
|
|
Loading…
Reference in New Issue