added IC secret to contact IS
This commit is contained in:
parent
efb9451211
commit
c840b2f762
|
@ -0,0 +1,44 @@
|
|||
package org.gcube.common.core.publisher.is.legacy;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.security.Owner;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
|
||||
public class ICSecret extends Secret{
|
||||
|
||||
private String context;
|
||||
|
||||
protected ICSecret(String context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Owner getOwner() {
|
||||
return new Owner("guest", Collections.emptyList(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getHTTPAuthorizationHeaders() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpired() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRefreshable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -21,7 +21,6 @@ import org.gcube.smartgears.context.application.ApplicationContext;
|
|||
import org.gcube.smartgears.context.container.ContainerContext;
|
||||
import org.gcube.smartgears.publishing.Publisher;
|
||||
import org.gcube.smartgears.publishing.SmartgearsProfilePublisher;
|
||||
import org.gcube.smartgears.security.AuthorizationProvider;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -58,7 +57,6 @@ public class LegacyISPublisher implements Publisher{
|
|||
}
|
||||
|
||||
|
||||
AuthorizationProvider provider = container.configuration().authorizationProvider();
|
||||
for (String context : filterICContexts(hostingNode.scopes().asCollection()))
|
||||
try {
|
||||
logger.info("publishing container in context {}", context);
|
||||
|
@ -70,7 +68,7 @@ public class LegacyISPublisher implements Publisher{
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}, provider.getSecretForContext(context));
|
||||
}, new ICSecret(context));
|
||||
}catch (Throwable e) {
|
||||
logger.error("error publishing container in context {}", context, e);
|
||||
}
|
||||
|
@ -97,7 +95,6 @@ public class LegacyISPublisher implements Publisher{
|
|||
resourcesCache.put(id, endpoint);
|
||||
}
|
||||
|
||||
AuthorizationProvider provider = application.container().configuration().authorizationProvider();
|
||||
for (String context : filterICContexts(endpoint.scopes().asCollection()))
|
||||
try {
|
||||
logger.info("publishing application in context {}", context);
|
||||
|
@ -109,7 +106,7 @@ public class LegacyISPublisher implements Publisher{
|
|||
logger.error("erro publishing application", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}, provider.getSecretForContext(context));
|
||||
}, new ICSecret(context));
|
||||
}catch (Throwable e) {
|
||||
logger.error("error publishing application profile in context {}", context, e);
|
||||
}
|
||||
|
@ -138,8 +135,6 @@ public class LegacyISPublisher implements Publisher{
|
|||
resourcesCache.put(id, hostingNode);
|
||||
}
|
||||
|
||||
AuthorizationProvider provider = container.configuration().authorizationProvider();
|
||||
|
||||
for (String context : contexts)
|
||||
if (isCompatibleScopeForRemove(hostingNode, context))
|
||||
try {
|
||||
|
@ -151,7 +146,7 @@ public class LegacyISPublisher implements Publisher{
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}, provider.getSecretForContext(context));
|
||||
}, new ICSecret(context));
|
||||
}catch (Throwable e) {
|
||||
logger.error("error removing container in context {}", context, e);
|
||||
}
|
||||
|
@ -166,7 +161,7 @@ public class LegacyISPublisher implements Publisher{
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}, provider.getSecretForContext(context));
|
||||
}, new ICSecret(context));
|
||||
}catch (Throwable e) {
|
||||
logger.error("error updating container in context {}", context, e);
|
||||
}
|
||||
|
@ -193,9 +188,7 @@ public class LegacyISPublisher implements Publisher{
|
|||
|
||||
resourcesCache.put(id, endpoint);
|
||||
}
|
||||
|
||||
AuthorizationProvider provider = application.container().configuration().authorizationProvider();
|
||||
|
||||
|
||||
//TODO: Review this
|
||||
for (String context : contexts)
|
||||
if (isCompatibleScopeForRemove(endpoint, context))
|
||||
|
@ -208,7 +201,7 @@ public class LegacyISPublisher implements Publisher{
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}, provider.getSecretForContext(context));
|
||||
}, new ICSecret(context));
|
||||
}catch (Throwable e) {
|
||||
logger.error("error removing container in context {}", context, e);
|
||||
}
|
||||
|
@ -223,7 +216,7 @@ public class LegacyISPublisher implements Publisher{
|
|||
}catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}, provider.getSecretForContext(context));
|
||||
}, new ICSecret(context));
|
||||
}catch (Throwable e) {
|
||||
logger.error("error updating application profile in context {}", context, e);
|
||||
}
|
||||
|
@ -233,9 +226,7 @@ public class LegacyISPublisher implements Publisher{
|
|||
|
||||
@Override
|
||||
public boolean update(ApplicationContext application) {
|
||||
|
||||
AuthorizationProvider provider = application.container().configuration().authorizationProvider();
|
||||
|
||||
|
||||
GCoreEndpoint endpoint;
|
||||
synchronized (resourcesCache) {
|
||||
String id = application.id();
|
||||
|
@ -252,7 +243,7 @@ public class LegacyISPublisher implements Publisher{
|
|||
}catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}, provider.getSecretForContext(context));
|
||||
}, new ICSecret(context));
|
||||
}catch (Throwable e) {
|
||||
logger.error("error updating application profile in context {}", context, e);
|
||||
}
|
||||
|
@ -274,8 +265,6 @@ public class LegacyISPublisher implements Publisher{
|
|||
resourcesCache.put(id, hostingNode);
|
||||
}
|
||||
|
||||
AuthorizationProvider provider = container.configuration().authorizationProvider();
|
||||
|
||||
for (String context : filterICContexts(hostingNode.scopes().asCollection()))
|
||||
try {
|
||||
logger.info("updating container in context {}", context);
|
||||
|
@ -287,7 +276,7 @@ public class LegacyISPublisher implements Publisher{
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}, provider.getSecretForContext(context));
|
||||
}, new ICSecret(context));
|
||||
}catch (Throwable e) {
|
||||
logger.error("error updating container in context {}", context, e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue