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 org.gcube.smartgears.configuration.ProxyAddress;
|
||||
import org.gcube.smartgears.persistence.PersistenceWriter;
|
||||
|
||||
/**
|
||||
|
@ -83,9 +82,6 @@ public interface ApplicationConfiguration {
|
|||
*/
|
||||
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 org.gcube.smartgears.configuration.ProxyAddress;
|
||||
import org.gcube.smartgears.configuration.container.ContainerConfiguration;
|
||||
import org.gcube.smartgears.persistence.PersistenceWriter;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -75,10 +74,6 @@ public class BridgedApplicationConfiguration implements ApplicationConfiguration
|
|||
return application.description();
|
||||
}
|
||||
|
||||
public ProxyAddress proxyAddress() {
|
||||
return application.proxyAddress();
|
||||
}
|
||||
|
||||
public ApplicationConfiguration description(String description) {
|
||||
return application.description(description);
|
||||
}
|
||||
|
@ -129,11 +124,4 @@ public class BridgedApplicationConfiguration implements ApplicationConfiguration
|
|||
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.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementRef;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
@ -33,6 +34,9 @@ public class DefaultApplicationConfiguration implements ApplicationConfiguration
|
|||
|
||||
String context;
|
||||
|
||||
@XmlAttribute(name = "proxied")
|
||||
private boolean proxied = true;
|
||||
|
||||
@XmlElement(name="name" , required=true)
|
||||
@NotNull
|
||||
String name;
|
||||
|
@ -48,9 +52,6 @@ public class DefaultApplicationConfiguration implements ApplicationConfiguration
|
|||
@XmlElement(name="description")
|
||||
String description="";
|
||||
|
||||
@IsValid
|
||||
ProxyAddress proxyAddress;
|
||||
|
||||
@XmlElementRef
|
||||
Set<Exclude> excludes= new LinkedHashSet<Exclude>();
|
||||
|
||||
|
@ -89,10 +90,6 @@ public class DefaultApplicationConfiguration implements ApplicationConfiguration
|
|||
return this;
|
||||
}
|
||||
|
||||
public ProxyAddress proxyAddress() {
|
||||
return proxyAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationConfiguration excludes(Exclude ... excludes) {
|
||||
this.excludes=new HashSet<Exclude>(Arrays.asList(excludes));
|
||||
|
@ -148,7 +145,7 @@ public class DefaultApplicationConfiguration implements ApplicationConfiguration
|
|||
|
||||
@Override
|
||||
public boolean proxied() {
|
||||
return proxyAddress!=null;
|
||||
return proxied;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -162,12 +159,6 @@ public class DefaultApplicationConfiguration implements ApplicationConfiguration
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationConfiguration proxyAddress(ProxyAddress proxyaddress) {
|
||||
this.proxyAddress = proxyaddress;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
|
||||
|
|
|
@ -114,7 +114,6 @@ public class ContainerConfigurationBinder {
|
|||
if (authorizationSection != null) {
|
||||
|
||||
String provider = authorizationSection.get("factory");
|
||||
String authEndpoint = authorizationSection.get("endpoint");
|
||||
AuthorizationProviderFactory<?> authProviderFactory;
|
||||
if (provider!=null) {
|
||||
try {
|
||||
|
@ -126,6 +125,8 @@ public class ContainerConfigurationBinder {
|
|||
} else
|
||||
authProviderFactory = new DefaultAuthorizationProviderFactory();
|
||||
|
||||
authorizationSection.to(authProviderFactory, "factory.");
|
||||
|
||||
|
||||
String type = authorizationSection.get("credentials.class");
|
||||
if (type ==null)
|
||||
|
@ -139,7 +140,7 @@ public class ContainerConfigurationBinder {
|
|||
}
|
||||
authorizationSection.to(credentials, "credentials.");
|
||||
|
||||
AuthorizationProvider authProvider = authProviderFactory.connect(credentials, authEndpoint);
|
||||
AuthorizationProvider authProvider = authProviderFactory.connect(credentials);
|
||||
|
||||
conf.setAuthorizationProvider(authProvider);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,6 @@ public class ApplicationProfileManager extends ApplicationLifecycleHandler {
|
|||
|
||||
activated();
|
||||
|
||||
schedulePeriodicUpdates();
|
||||
// note we don't fire profile events, but wait for the final startup
|
||||
// outcome which
|
||||
// will result in a state change. only then we publish and store the
|
||||
|
|
|
@ -66,7 +66,6 @@ public class ContainerProfileManager extends ContainerHandler {
|
|||
|
||||
activated();
|
||||
|
||||
schedulePeriodicUpdates();
|
||||
// note we don't fire profile events, but wait for the final startup
|
||||
// outcome which
|
||||
// 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) {
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.gcube.smartgears.security;
|
|||
|
||||
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,16 +1,35 @@
|
|||
package org.gcube.smartgears.security.defaults;
|
||||
|
||||
import org.gcube.common.validator.annotations.NotEmpty;
|
||||
import org.gcube.smartgears.security.AuthorizationProviderFactory;
|
||||
import org.gcube.smartgears.security.Credentials;
|
||||
import org.gcube.smartgears.security.SimpleCredentials;
|
||||
|
||||
public class DefaultAuthorizationProviderFactory implements AuthorizationProviderFactory<DefaultAuthorizationProvider>{
|
||||
|
||||
@NotEmpty
|
||||
private String endpoint;
|
||||
|
||||
@Override
|
||||
public DefaultAuthorizationProvider connect(Credentials credentials, String enpoint) {
|
||||
public DefaultAuthorizationProvider connect(Credentials credentials) {
|
||||
if (!SimpleCredentials.class.isInstance(credentials))
|
||||
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]
|
||||
; not mandatory
|
||||
SmartGearsDistribution = 0.0.1
|
||||
SmartGearsDistribution = 1.0.0
|
||||
SmartGearsDistributionBundle = UnBundled
|
||||
|
||||
[site]
|
||||
; mandatory
|
||||
; optional fields: latitude, logitude
|
||||
country = it
|
||||
location = rome
|
||||
|
||||
|
@ -26,11 +25,12 @@ location = rome
|
|||
;hostname = proxy
|
||||
;port = 80
|
||||
|
||||
|
||||
[authorization]
|
||||
; mandatory
|
||||
; optional fields: provider 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.clientID = testClient
|
||||
credentials.secret = testSecret
|
||||
|
|
Loading…
Reference in New Issue