add feature 24254, first version
This commit is contained in:
parent
cb4b10caf0
commit
b70ed135e9
|
@ -3,20 +3,28 @@
|
|||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [v1.4.0-SNAPSHOT] - [2023-02-15]
|
||||
|
||||
- Feature #24254 simple serviceEndpoint creation
|
||||
|
||||
|
||||
## [v1.3.0] - [2023-02-09]
|
||||
|
||||
- add support for UMA token
|
||||
- Feature #24253 add support for decrypted ServiceEndpoint
|
||||
- update lombok library to 1.18.4 with scope provided
|
||||
|
||||
|
||||
## [v1.2.0] - [2021-06-08]
|
||||
|
||||
- Feature #21584 added support for /ServiceEndpoint/{category} REST call
|
||||
|
||||
|
||||
## [v1.1.0-SNAPSHOT] - [2016-10-03]
|
||||
|
||||
- porting to auth v.2
|
||||
|
||||
|
||||
## [v1.0.0] - [2015-07-01]
|
||||
|
||||
- First commit
|
2
pom.xml
2
pom.xml
|
@ -11,7 +11,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.information-system</groupId>
|
||||
<artifactId>icproxy</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0-SNAPSHOT</version>
|
||||
<name>ICProxy</name>
|
||||
|
||||
<packaging>war</packaging>
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package org.gcube.informationsystem.icproxy.profiles;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
public class ServiceEndpointProfile {
|
||||
@Getter
|
||||
@Setter
|
||||
private String category;
|
||||
@Getter
|
||||
@Setter
|
||||
private String name;
|
||||
@Getter
|
||||
@Setter
|
||||
private String platform="d4science";
|
||||
@Getter
|
||||
@Setter
|
||||
private String accessPointName;
|
||||
@Getter
|
||||
@Setter (AccessLevel.PROTECTED)
|
||||
private String accessPointAddress;
|
||||
@Getter
|
||||
@Setter (AccessLevel.PROTECTED)
|
||||
private String accessPointUsername;
|
||||
@Getter
|
||||
@Setter (AccessLevel.PROTECTED)
|
||||
private String accessPointPass;
|
||||
}
|
|
@ -13,8 +13,12 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
|
||||
import org.gcube.common.keycloak.model.ModelUtils;
|
||||
import org.gcube.common.resources.gcore.*;
|
||||
import org.gcube.common.resources.gcore.common.Platform;
|
||||
import org.gcube.common.resources.gcore.utils.Group;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.informationsystem.icproxy.profiles.ServiceEndpointProfile;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisher;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.gcube.common.encryption.StringEncrypter;
|
||||
|
@ -80,6 +84,28 @@ public class ServiceEndpointResource {
|
|||
return builder.toString();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_XML)
|
||||
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
|
||||
public ServiceEndpoint create(ServiceEndpointProfile resourceProfile) {
|
||||
log.info("Try to create new serviceEndpoint profile {} in {}",resourceProfile, ScopeProvider.instance.get());
|
||||
if (Objects.nonNull(resourceProfile) && isRoleEnabled()){
|
||||
ServiceEndpoint newResource= new ServiceEndpoint();
|
||||
ServiceEndpoint.Profile profile=newResource.newProfile().category(resourceProfile.getCategory()).name(resourceProfile.getName());
|
||||
profile.newPlatform().name(resourceProfile.getPlatform());
|
||||
ServiceEndpoint.AccessPoint ap=new ServiceEndpoint.AccessPoint();
|
||||
ap.name(resourceProfile.getAccessPointName());
|
||||
ap.address(resourceProfile.getAccessPointAddress());
|
||||
ap.credentials(resourceProfile.getAccessPointPass(), resourceProfile.getAccessPointUsername());
|
||||
profile.accessPoints().add(ap);
|
||||
registerSE(newResource);
|
||||
return newResource;
|
||||
}else{
|
||||
throw new RuntimeException("ServiceEndpoint profile is null or user not enabled");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private SimpleQuery getQuery(String resourceName, String resourceCategory){
|
||||
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||
query.addCondition(String.format("$resource/Profile/Name/text() eq '%s'",resourceName));
|
||||
|
@ -140,4 +166,12 @@ public class ServiceEndpointResource {
|
|||
log.info("user not authorized, sorry");
|
||||
return false;
|
||||
}
|
||||
private static String registerSE(ServiceEndpoint toRegister) {
|
||||
RegistryPublisher rp= RegistryPublisherFactory.create();
|
||||
if(log.isDebugEnabled())
|
||||
Resources.print(toRegister);
|
||||
Resource r=rp.create(toRegister);
|
||||
return r.id();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue