Profile and App events updated
This commit is contained in:
parent
6f999bcedc
commit
08781a5f3a
|
@ -2,7 +2,6 @@ package org.gcube.smartgears.configuration.application;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.gcube.smartgears.configuration.ProxyAddress;
|
|
||||||
import org.gcube.smartgears.persistence.PersistenceWriter;
|
import org.gcube.smartgears.persistence.PersistenceWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,9 +82,6 @@ public interface ApplicationConfiguration {
|
||||||
*/
|
*/
|
||||||
ApplicationConfiguration description(String description);
|
ApplicationConfiguration description(String description);
|
||||||
|
|
||||||
ProxyAddress proxyAddress();
|
|
||||||
|
|
||||||
ApplicationConfiguration proxyAddress(ProxyAddress proxyaddress);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,7 +2,6 @@ package org.gcube.smartgears.configuration.application;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.gcube.smartgears.configuration.ProxyAddress;
|
|
||||||
import org.gcube.smartgears.configuration.container.ContainerConfiguration;
|
import org.gcube.smartgears.configuration.container.ContainerConfiguration;
|
||||||
import org.gcube.smartgears.persistence.PersistenceWriter;
|
import org.gcube.smartgears.persistence.PersistenceWriter;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -74,10 +73,6 @@ public class BridgedApplicationConfiguration implements ApplicationConfiguration
|
||||||
public String description() {
|
public String description() {
|
||||||
return application.description();
|
return application.description();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProxyAddress proxyAddress() {
|
|
||||||
return application.proxyAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationConfiguration description(String description) {
|
public ApplicationConfiguration description(String description) {
|
||||||
return application.description(description);
|
return application.description(description);
|
||||||
|
@ -129,11 +124,4 @@ public class BridgedApplicationConfiguration implements ApplicationConfiguration
|
||||||
return application.includes(includes);
|
return application.includes(includes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ApplicationConfiguration proxyAddress(ProxyAddress proxyaddress) {
|
|
||||||
return application.proxyAddress(proxyaddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlElementRef;
|
import javax.xml.bind.annotation.XmlElementRef;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
@ -32,7 +33,10 @@ import org.gcube.smartgears.persistence.PersistenceWriter;
|
||||||
public class DefaultApplicationConfiguration implements ApplicationConfiguration {
|
public class DefaultApplicationConfiguration implements ApplicationConfiguration {
|
||||||
|
|
||||||
String context;
|
String context;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "proxied")
|
||||||
|
private boolean proxied = true;
|
||||||
|
|
||||||
@XmlElement(name="name" , required=true)
|
@XmlElement(name="name" , required=true)
|
||||||
@NotNull
|
@NotNull
|
||||||
String name;
|
String name;
|
||||||
|
@ -47,10 +51,7 @@ public class DefaultApplicationConfiguration implements ApplicationConfiguration
|
||||||
|
|
||||||
@XmlElement(name="description")
|
@XmlElement(name="description")
|
||||||
String description="";
|
String description="";
|
||||||
|
|
||||||
@IsValid
|
|
||||||
ProxyAddress proxyAddress;
|
|
||||||
|
|
||||||
@XmlElementRef
|
@XmlElementRef
|
||||||
Set<Exclude> excludes= new LinkedHashSet<Exclude>();
|
Set<Exclude> excludes= new LinkedHashSet<Exclude>();
|
||||||
|
|
||||||
|
@ -88,11 +89,7 @@ public class DefaultApplicationConfiguration implements ApplicationConfiguration
|
||||||
this.context=context;
|
this.context=context;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProxyAddress proxyAddress() {
|
|
||||||
return proxyAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationConfiguration excludes(Exclude ... excludes) {
|
public ApplicationConfiguration excludes(Exclude ... excludes) {
|
||||||
this.excludes=new HashSet<Exclude>(Arrays.asList(excludes));
|
this.excludes=new HashSet<Exclude>(Arrays.asList(excludes));
|
||||||
|
@ -148,7 +145,7 @@ public class DefaultApplicationConfiguration implements ApplicationConfiguration
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean proxied() {
|
public boolean proxied() {
|
||||||
return proxyAddress!=null;
|
return proxied;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -161,12 +158,6 @@ public class DefaultApplicationConfiguration implements ApplicationConfiguration
|
||||||
this.persistenceManager=manager;
|
this.persistenceManager=manager;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ApplicationConfiguration proxyAddress(ProxyAddress proxyaddress) {
|
|
||||||
this.proxyAddress = proxyaddress;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() {
|
public void validate() {
|
||||||
|
|
|
@ -114,7 +114,6 @@ public class ContainerConfigurationBinder {
|
||||||
if (authorizationSection != null) {
|
if (authorizationSection != null) {
|
||||||
|
|
||||||
String provider = authorizationSection.get("factory");
|
String provider = authorizationSection.get("factory");
|
||||||
String authEndpoint = authorizationSection.get("endpoint");
|
|
||||||
AuthorizationProviderFactory<?> authProviderFactory;
|
AuthorizationProviderFactory<?> authProviderFactory;
|
||||||
if (provider!=null) {
|
if (provider!=null) {
|
||||||
try {
|
try {
|
||||||
|
@ -126,6 +125,8 @@ public class ContainerConfigurationBinder {
|
||||||
} else
|
} else
|
||||||
authProviderFactory = new DefaultAuthorizationProviderFactory();
|
authProviderFactory = new DefaultAuthorizationProviderFactory();
|
||||||
|
|
||||||
|
authorizationSection.to(authProviderFactory, "factory.");
|
||||||
|
|
||||||
|
|
||||||
String type = authorizationSection.get("credentials.class");
|
String type = authorizationSection.get("credentials.class");
|
||||||
if (type ==null)
|
if (type ==null)
|
||||||
|
@ -139,7 +140,7 @@ public class ContainerConfigurationBinder {
|
||||||
}
|
}
|
||||||
authorizationSection.to(credentials, "credentials.");
|
authorizationSection.to(credentials, "credentials.");
|
||||||
|
|
||||||
AuthorizationProvider authProvider = authProviderFactory.connect(credentials, authEndpoint);
|
AuthorizationProvider authProvider = authProviderFactory.connect(credentials);
|
||||||
|
|
||||||
conf.setAuthorizationProvider(authProvider);
|
conf.setAuthorizationProvider(authProvider);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,6 @@ public class ApplicationProfileManager extends ApplicationLifecycleHandler {
|
||||||
|
|
||||||
activated();
|
activated();
|
||||||
|
|
||||||
schedulePeriodicUpdates();
|
|
||||||
// note we don't fire profile events, but wait for the final startup
|
// note we don't fire profile events, but wait for the final startup
|
||||||
// outcome which
|
// outcome which
|
||||||
// will result in a state change. only then we publish and store the
|
// will result in a state change. only then we publish and store the
|
||||||
|
|
|
@ -66,7 +66,6 @@ public class ContainerProfileManager extends ContainerHandler {
|
||||||
|
|
||||||
activated();
|
activated();
|
||||||
|
|
||||||
schedulePeriodicUpdates();
|
|
||||||
// note we don't fire profile events, but wait for the final startup
|
// note we don't fire profile events, but wait for the final startup
|
||||||
// outcome which
|
// outcome which
|
||||||
// will result in a state change. only then we publish and store the
|
// will result in a state change. only then we publish and store the
|
||||||
|
|
|
@ -276,7 +276,7 @@ public class ApplicationManager {
|
||||||
public void contextInitialized(ServletContextEvent sce) {
|
public void contextInitialized(ServletContextEvent sce) {
|
||||||
log.info("initilizing context {} ",context.name());
|
log.info("initilizing context {} ",context.name());
|
||||||
|
|
||||||
context.events().fire(context.application().getContextPath(), ApplicationLifecycle.activation);
|
context.events().fire(context, ApplicationLifecycle.activation);
|
||||||
log.info("webApp {} initialized ",context.name());
|
log.info("webApp {} initialized ",context.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package org.gcube.smartgears.security;
|
||||||
|
|
||||||
public interface AuthorizationProviderFactory<T extends AuthorizationProvider> {
|
public interface AuthorizationProviderFactory<T extends AuthorizationProvider> {
|
||||||
|
|
||||||
T connect(Credentials credentials, String endpoint);
|
T connect(Credentials credentials);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,4 +70,9 @@ public class DefaultAuthorizationProvider implements AuthorizationProvider {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
//TODO: remove when whnManager will be removed
|
||||||
|
public SimpleCredentials getCredentials() {
|
||||||
|
return credentials;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,36 @@
|
||||||
package org.gcube.smartgears.security.defaults;
|
package org.gcube.smartgears.security.defaults;
|
||||||
|
|
||||||
|
import org.gcube.common.validator.annotations.NotEmpty;
|
||||||
import org.gcube.smartgears.security.AuthorizationProviderFactory;
|
import org.gcube.smartgears.security.AuthorizationProviderFactory;
|
||||||
import org.gcube.smartgears.security.Credentials;
|
import org.gcube.smartgears.security.Credentials;
|
||||||
import org.gcube.smartgears.security.SimpleCredentials;
|
import org.gcube.smartgears.security.SimpleCredentials;
|
||||||
|
|
||||||
public class DefaultAuthorizationProviderFactory implements AuthorizationProviderFactory<DefaultAuthorizationProvider>{
|
public class DefaultAuthorizationProviderFactory implements AuthorizationProviderFactory<DefaultAuthorizationProvider>{
|
||||||
|
|
||||||
|
@NotEmpty
|
||||||
|
private String endpoint;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DefaultAuthorizationProvider connect(Credentials credentials, String enpoint) {
|
public DefaultAuthorizationProvider connect(Credentials credentials) {
|
||||||
if (!SimpleCredentials.class.isInstance(credentials))
|
if (!SimpleCredentials.class.isInstance(credentials))
|
||||||
throw new IllegalArgumentException("invalid credential type passed");
|
throw new IllegalArgumentException("invalid credential type passed");
|
||||||
return new DefaultAuthorizationProvider((SimpleCredentials)credentials, enpoint);
|
if (this.endpoint == null || this.endpoint.isEmpty())
|
||||||
|
throw new IllegalArgumentException("invalid enpoint passed");
|
||||||
|
return new DefaultAuthorizationProvider((SimpleCredentials)credentials, this.endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "DefaultAuthorizationProviderFactory [endpoint=" + endpoint + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEndpoint() {
|
||||||
|
return endpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndpoint(String endpoint) {
|
||||||
|
this.endpoint = endpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,11 @@ publicationFrequencyInSeconds = 60
|
||||||
|
|
||||||
[properties]
|
[properties]
|
||||||
; not mandatory
|
; not mandatory
|
||||||
SmartGearsDistribution = 0.0.1
|
SmartGearsDistribution = 1.0.0
|
||||||
SmartGearsDistributionBundle = UnBundled
|
SmartGearsDistributionBundle = UnBundled
|
||||||
|
|
||||||
[site]
|
[site]
|
||||||
; mandatory
|
; mandatory
|
||||||
; optional fields: latitude, logitude
|
|
||||||
country = it
|
country = it
|
||||||
location = rome
|
location = rome
|
||||||
|
|
||||||
|
@ -26,11 +25,12 @@ location = rome
|
||||||
;hostname = proxy
|
;hostname = proxy
|
||||||
;port = 80
|
;port = 80
|
||||||
|
|
||||||
|
|
||||||
[authorization]
|
[authorization]
|
||||||
; mandatory
|
; mandatory
|
||||||
; optional fields: provider factory (=org.gcube.smartgears.security.defaults.DefaultAuthorizationProviderFactory)
|
; optional fields: provider factory (=org.gcube.smartgears.security.defaults.DefaultAuthorizationProviderFactory)
|
||||||
factory = org.gcube.smartgears.security.defaults.DefaultAuthorizationProviderFactory
|
factory = org.gcube.smartgears.security.defaults.DefaultAuthorizationProviderFactory
|
||||||
endpoint = https://accounts.dev.d4science.org/auth/realms/d4science
|
factory.endpoint = https://accounts.dev.d4science.org/auth/realms/d4science/protocol/openid-connect/token
|
||||||
credentials.class = org.gcube.smartgears.security.SimpleCredentials
|
credentials.class = org.gcube.smartgears.security.SimpleCredentials
|
||||||
credentials.clientID = testClient
|
credentials.clientID = testClient
|
||||||
credentials.secret = testSecret
|
credentials.secret = testSecret
|
||||||
|
|
Loading…
Reference in New Issue