Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@
import org.geotools.referencing.ReferencingFactoryFinder;
import org.geotools.util.factory.Hints;
import org.integratedmodelling.kim.api.IPrototype;
import org.integratedmodelling.klab.Authentication;
import org.integratedmodelling.klab.Dataflows;
import org.integratedmodelling.klab.Klab;
import org.integratedmodelling.klab.Version;
import org.integratedmodelling.klab.api.auth.IIdentity;
import org.integratedmodelling.klab.api.auth.IUserIdentity;
import org.integratedmodelling.klab.api.data.IResource;
import org.integratedmodelling.klab.api.data.IResourceCalculator;
import org.integratedmodelling.klab.api.data.adapters.IResourceAdapter;
Expand All @@ -43,6 +47,11 @@
import org.integratedmodelling.klab.ogc.vector.wfs.WfsPublisher;
import org.integratedmodelling.klab.ogc.vector.wfs.WfsValidator;

import klab.commons.customProperties.CustomPropertyKey;
import klab.commons.customProperties.auth.AuthType;
import klab.commons.customProperties.auth.AuthenticatedUrlClient;
import klab.commons.customProperties.auth.BasicAuth;

/**
* The Class WfsAdapter.
*/
Expand Down Expand Up @@ -97,7 +106,7 @@ public IResourceEncoder getEncoder() {
public static WFSDataStore getDatastore(String serverUrl, Version version) {

WFSDataStore ret = dataStores.get(serverUrl);

if (ret == null) {

if (lastTry.get(serverUrl) != null
Expand All @@ -118,12 +127,16 @@ public static WFSDataStore getDatastore(String serverUrl, Version version) {

String getCapabilities = serverUrl + "?SERVICE=wfs&REQUEST=getCapabilities&version=" + version;
WFSDataStoreFactory dsf = new WFSDataStoreFactory();

Map<String, Serializable> connectionParameters = new HashMap<>();

IUserIdentity userData = Authentication.INSTANCE.getAuthenticatedIdentity(IUserIdentity.class);
AuthenticatedUrlClient.prepareWFSAuthenticationParameters(serverUrl, connectionParameters ,userData.getGroups(), CustomPropertyKey.GEOSERVER_KEYS);

connectionParameters.put(WFSDataStoreFactory.URL.key, getCapabilities);
connectionParameters.put(WFSDataStoreFactory.TIMEOUT.key, wfsTimeout);
connectionParameters.put(WFSDataStoreFactory.BUFFER_SIZE.key, wfsBufsize);

/*
* TODO all other parameters
*/
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

import java.util.Objects;


/**
* Custom properties with visibility field
* @author Enrico Girotto
*
*/

public class CustomPropertyRest {
public class CustomPropertyRest implements ICustomProperty{

private String key;
private String value;
private boolean onlyAdmin;
private Object valueObject;
private boolean onlyAdmin;

public CustomPropertyRest() {}

Expand All @@ -22,19 +22,36 @@ public CustomPropertyRest(String key, String value, boolean onlyAdmin) {
this.value = value;
this.onlyAdmin = onlyAdmin;
}

public CustomPropertyRest(String key, String value, boolean onlyAdmin, CustomPropertyTypeRest valueObject) {
this.key = key;
this.value = value;
this.valueObject = valueObject;
this.onlyAdmin = onlyAdmin;
}

public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
@Override
public String getValue() {
return value;
return this.value;
}
public void setValue(String value) {
this.value = value;
}

public Object getValueObject() {
return valueObject;
}

public void setValueObject(Object valueObject2) {
this.valueObject = valueObject2;
}

public boolean isOnlyAdmin() {
return onlyAdmin;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.integratedmodelling.klab.rest;


public interface CustomPropertyTypeRest {
String getType();
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package org.integratedmodelling.klab.rest;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

Expand All @@ -21,6 +23,7 @@ public class Group {
private List<String> projectUrls = new ArrayList<String>();
private List<ObservableReference> observables = new ArrayList<ObservableReference>();
private Set<CustomPropertyRest> customProperties= new HashSet<CustomPropertyRest>();
private Map<String, CustomPropertyRest> customPropertyMap = new HashMap<>();
private List<String> dependsOn = new ArrayList<String>();

public Group() {
Expand Down Expand Up @@ -195,8 +198,18 @@ public List<String> getDependsOn() {
public void setDependsOn(List<String> dependsOn) {
this.dependsOn = dependsOn;
}



@Override
public Map<String, CustomPropertyRest> getCustomPropertyMap() {
return customPropertyMap;
}

public void setCustomPropertyMap(Map<String, CustomPropertyRest> customPropertyMap) {
this.customPropertyMap = customPropertyMap;
}

@Override
public int hashCode() {
return Objects.hash(complimentary, customProperties, defaultExpirationTime, description, iconUrl, id, maxUpload,
observables, optIn, projectUrls, sshKey, worldview, dependsOn);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.integratedmodelling.klab.rest;

public interface ICustomProperty {
String getKey();
String getValue();
boolean isOnlyAdmin();
}
5 changes: 5 additions & 0 deletions klab.authentication/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<artifactId>org.integratedmodelling.klab.api</artifactId>
<version>${klab.version}</version>
</dependency>
<dependency>
<groupId>org.integratedmodelling</groupId>
<artifactId>klab.commons</artifactId>
<version>${klab.version}</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@

import com.google.common.collect.Sets;

import klab.commons.customProperties.utils.CustomPropertyUtils;

public enum Authentication implements IAuthenticationService {

/**
Expand Down Expand Up @@ -384,7 +386,7 @@ public IUserIdentity authenticate(ICertificate certificate) throws KlabAuthoriza
NetworkSession networkSession = new NetworkSession(authentication.getUserData().getToken(), hub);

ret = new KlabUser(authentication.getUserData(), authentication.getAuthentication(), networkSession);

Network.INSTANCE.buildNetwork(authentication);

Logging.INSTANCE.info("User " + ((IUserIdentity) ret).getUsername() + " logged in through hub " + hubNode.getId()
Expand Down Expand Up @@ -424,6 +426,7 @@ public IUserIdentity authenticate(ICertificate certificate) throws KlabAuthoriza
}

if (ret != null) {
CustomPropertyUtils.deserializeCustomProperties(ret.getGroups());
registerIdentity(ret);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.integratedmodelling.klab.api.auth.IIdentity;
import org.integratedmodelling.klab.api.auth.IUserIdentity;
import org.integratedmodelling.klab.rest.AuthenticatedIdentity;
import org.integratedmodelling.klab.rest.CustomPropertyRest;
import org.integratedmodelling.klab.rest.Group;
import org.integratedmodelling.klab.rest.IdentityReference;
import org.joda.time.DateTime;
Expand Down
40 changes: 40 additions & 0 deletions klab.commons/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<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"/>
<attribute name="optional" 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"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<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="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions klab.commons/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>klab.commons</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
6 changes: 6 additions & 0 deletions klab.commons/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
eclipse.preferences.version=1
encoding//src/main/java=utf-8
encoding//src/main/resources=utf-8
encoding//src/test/java=utf-8
encoding//src/test/resources=utf-8
encoding/<project>=utf-8
8 changes: 8 additions & 0 deletions klab.commons/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=11
4 changes: 4 additions & 0 deletions klab.commons/.settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
Loading