Commit cdc843a1 authored by Matija Obreza's avatar Matija Obreza
Browse files

API Documentation updated

- Upgrade to application-blocks-security:1.3-SNAPSHOT
- Removed obsolete tests
parent 52d7317e
...@@ -3,37 +3,41 @@ ...@@ -3,37 +3,41 @@
== Managing Passport Data == Managing Passport Data
Passport data is based on FAO Multi-Crop Passport Descriptors <<mcpd2>> format. Passport data is based on FAO Multi-Crop Passport Descriptors <<mcpd2>> format.
Accession records are *upserted*, meaning that when the matching accession record Accession records are *upserted*, meaning that when the matching accession record
. exists, it will be updated . exists, it will be updated
. does not exist, a new record will be created . does not exist, a new record will be created
Accession data in the database will be updated with whatever data is provided in the Accession data in the database will be updated with whatever data is provided in the
request JSON. request JSON.
=== Accession identity === Accession identity
Prior to full adoption of Permanent Unique Identifiers for Germplasm, accessions could be Prior to full adoption of Permanent Unique Identifiers for Germplasm, accessions could be
identified by the holding institute code (INSTCODE) and the accession number (ACCENUMB). identified by the holding institute code (INSTCODE) and the accession number (ACCENUMB).
Genebanks maintaining two or more collections of crops would sometimes use the same Genebanks maintaining two or more collections of crops would sometimes use the same
accession number, unique within one collection. accession number, unique within one collection.
Genesys uses the *instCode*, *acceNumb* and *genus* triplet to uniquely identify an Genesys uses the *instCode*, *acceNumb* and *genus* triplet to uniquely identify an
accession in an institute: accession in an institute. For accessions with a <<doi, DOI>> assigned in <<glis, GLIS>> it will
use the DOI to uniquely identify the record:
[source,json,linenums] [source,json,linenums]
---- ----
{ {
"instCode": "NGA039", <1> "instCode": "NGA039", <1>
"acceNumb": "TMp-123", <2> "doi": "10.1054/12A1~", <2>
"genus": "Musa" <3> "acceNumb": "TMp-123", <3>
"genus": "Musa", <4>
...
} }
---- ----
<1> Holding institute code (INSTCODE) <1> Holding institute code (INSTCODE)
<2> Accession number (ACCENUMB) <2> DOI of the accession as registered in GLIS
<3> Genus (GENUS) <3> Accession number (ACCENUMB)
<4> Genus (GENUS)
=== JSON data model === JSON data model
...@@ -54,6 +58,7 @@ All other fields are optional. ...@@ -54,6 +58,7 @@ All other fields are optional.
---- ----
{ {
"instCode": "XYZ111", "instCode": "XYZ111",
"doi": "10.1231/14S41Q",
"acceNumb": "M12345", "acceNumb": "M12345",
"cropName": "banana", "cropName": "banana",
"genus": "Musa", "genus": "Musa",
...@@ -177,8 +182,8 @@ as `null`. Not providing a field means the field in the database should not be m ...@@ -177,8 +182,8 @@ as `null`. Not providing a field means the field in the database should not be m
=== Insert or update accessions === Insert or update accessions
REST endpoint URL `/api/v0/acn/{instCode}/upsert` allows for inserting new accessions REST endpoint URL `/api/v0/acn/{instCode}/upsert` allows for inserting new accessions
or updating existing records in Genesys. It accepts a JSON array of Accession JSON objects. or updating existing records in Genesys. It accepts a JSON array of Accession JSON objects.
The array provides for sending batches of 50 or 100 accessions in one call, reducing The array provides for sending batches of 50 or 100 accessions in one call, reducing
the HTTP overhead and improving performance. the HTTP overhead and improving performance.
...@@ -223,6 +228,7 @@ POST /api/v0/acn/SYR002/delete ...@@ -223,6 +228,7 @@ POST /api/v0/acn/SYR002/delete
[bibliography] [bibliography]
- [[[mcpd2]]] Alercia, A; Diulgheroff, S; Mackay, M. - [[[mcpd2]]] Alercia, A; Diulgheroff, S; Mackay, M.
http://www.bioversityinternational.org/e-library/publications/detail/faobioversity-multi-crop-passport-descriptors-v2-mcpd-v2/[FAO/Bioversity Multi-Crop Passport Descriptors V.2]. 2012. http://www.bioversityinternational.org/e-library/publications/detail/faobioversity-multi-crop-passport-descriptors-v2-mcpd-v2/[FAO/Bioversity Multi-Crop Passport Descriptors V.2]. 2012.
- [[[glis]]] ITPGRFA Secretariat
http://www.fao.org/plant-treaty/areas-of-work/global-information-system/en/[Global Information System].
...@@ -6,12 +6,12 @@ Access to selected resources in Genesys is protected and user permissions are ch ...@@ -6,12 +6,12 @@ Access to selected resources in Genesys is protected and user permissions are ch
any API action is executed. Each organization contributing data to Genesys will have any API action is executed. Each organization contributing data to Genesys will have
one or more registered user accounts on Genesys. one or more registered user accounts on Genesys.
To modify any data in Genesys, you will need appropriate permissions. To modify any data in Genesys, you will need appropriate permissions.
Permission to access and manage data for the organization is granted by Permission to access and manage data for the organization is granted by
helpdesk@genesys-pgr.org upon request. Please contact helpdesk@genesys-pgr.org with the list helpdesk@genesys-pgr.org upon request. Please contact helpdesk@genesys-pgr.org with the list
of WIEWS codes of institutes you wish to manage. of WIEWS codes of institutes you wish to manage.
To access resources with the APIs described in this manual, you will first need to To access resources with the APIs described in this manual, you will first need to
create a user account. The simplest is to https://sandbox.genesys-pgr.org/google/login[use your Google+ account] create a user account. The simplest is to https://sandbox.genesys-pgr.org/google/login[use your Google+ account]
or alternatively https://sandbox.genesys-pgr.org/registration[creating an account manually]. or alternatively https://sandbox.genesys-pgr.org/registration[creating an account manually].
...@@ -20,17 +20,17 @@ image::user-account-create.png[role="text-center"] ...@@ -20,17 +20,17 @@ image::user-account-create.png[role="text-center"]
Access to the APIs is managed by https://en.wikipedia.org/wiki/OAuth#OAuth_2.0[OAuth 2.0] protocol and implemented Access to the APIs is managed by https://en.wikipedia.org/wiki/OAuth#OAuth_2.0[OAuth 2.0] protocol and implemented
using http://docs.spring.io/spring-security/oauth/[spring-security OAuth] using http://docs.spring.io/spring-security/oauth/[spring-security OAuth]
modules. All API access is over HTTPS, and accessed from the https://www.genesys-pgr.org domain or modules. All API access is over HTTPS, and accessed from the https://www.genesys-pgr.org domain or
through https://sandbox.genesys-pgr.org for testing purposes. through https://sandbox.genesys-pgr.org for testing purposes.
To obtain OAuth access and refresh tokens, you will first need a valid Client ID and Client Secret. To obtain OAuth access and refresh tokens, you will first need a valid Client ID and Client Secret.
These are generated by helpdesk@genesys-pgr.org for each individual consumer application. These are generated by helpdesk@genesys-pgr.org for each individual consumer application.
The ID and Secret listed below are valid for the Sandbox environment and allows of out-of-band authentication The ID and Secret listed below are valid for the Sandbox environment and allows of out-of-band authentication
when using `curl` in the examples in this manual. when using `curl` in the examples in this manual.
[cols="1,2"] [cols="1,2"]
.Client ID and Secret for OOB .Client ID and Secret for OOB
|=== |===
|Client ID |Client ID
|`dLCiR.MzwkNha18ImEcw0ADli0@sandbox.genesys-pgr.org` |`dLCiR.MzwkNha18ImEcw0ADli0@sandbox.genesys-pgr.org`
...@@ -42,17 +42,17 @@ when using `curl` in the examples in this manual. ...@@ -42,17 +42,17 @@ when using `curl` in the examples in this manual.
=== Obtaining the access token === Obtaining the access token
Most OAuth libraries, including https://bitbucket.org/genesys2/genesys-client-api[genesys-client-api] Most OAuth libraries, including https://bitbucket.org/genesys2/genesys-client-api[genesys-client-api]
Java library, will automatically obtain the access token following the OAuth protocol. This Java library, will automatically obtain the access token following the OAuth protocol. This
section describes how to manually obtain the tokens. section describes how to manually obtain the tokens.
Log-in to Genesys with your account or Google+ Log-in to Genesys with your account or Google+
Obtain a verifier code by granting access to the "Genesys API reference" client. This is Obtain a verifier code by granting access to the "Genesys API reference" client. This is
initiated by opening the authorization URL in a browser (please substitute the CLIENTID and SECRET initiated by opening the authorization URL in a browser (please substitute the CLIENTID and SECRET
with valid data): with valid data):
---- ----
https://sandbox.genesys-pgr.org/oauth/authorize?client_id=CLIENTID&client_secret=SECRET&response_type=code&redirect_uri=oob&scope=read%2Cwrite https://sandbox.genesys-pgr.org/oauth/authorize?client_id=CLIENTID&client_secret=SECRET&response_type=code&redirect_uri=oob&scope=write
---- ----
The server will prompt you to authorize the access to your protected resources on Genesys. The server will prompt you to authorize the access to your protected resources on Genesys.
...@@ -63,7 +63,7 @@ Copy the authorization code: *THECODE* (looks like: 7wXP1r) and from shell, exec ...@@ -63,7 +63,7 @@ Copy the authorization code: *THECODE* (looks like: 7wXP1r) and from shell, exec
$ curl 'https://sandbox.genesys-pgr.org/oauth/token?grant_type=authorization_code&client_id=CLIENTID&client_secret=SECRET&redirect_uri=oob&code=THECODE' $ curl 'https://sandbox.genesys-pgr.org/oauth/token?grant_type=authorization_code&client_id=CLIENTID&client_secret=SECRET&redirect_uri=oob&code=THECODE'
---- ----
The server will respond with access token details in JSON format: The server will respond with access token details in JSON format:
[source,json] [source,json]
---- ----
...@@ -76,7 +76,7 @@ The server will respond with access token details in JSON format: ...@@ -76,7 +76,7 @@ The server will respond with access token details in JSON format:
} }
---- ----
You can use the access token to sign future HTTP requests to the API by adding a HTTP request header: You can use the access token to sign future HTTP requests to the API by adding a HTTP request header:
[source,http] [source,http]
---- ----
...@@ -97,10 +97,20 @@ or include it in the request URL as a query string parameter: ...@@ -97,10 +97,20 @@ or include it in the request URL as a query string parameter:
$ curl 'https://sandbox.genesys-pgr.org/api/v0/me?access_token=OAUTH-ACCESS-TOKEN' $ curl 'https://sandbox.genesys-pgr.org/api/v0/me?access_token=OAUTH-ACCESS-TOKEN'
---- ----
=== System-to-System integration
With Genesys release 2.3 the *Client authentication grant* is also supported. Kindly
contact the helpdesk@genesys-pgr.org for information how to enable system-to-system
integration and to grant your Client the appropriate permissions on Genesys.
**Note**: The client will be able to modify any data on Genesys on your behalf.
Read the section <<oauth, Client Credential Grant>>.
=== Using the refresh token === Using the refresh token
OAuth access tokens have a fairly short lifetime. When an access token expires, the OAuth access tokens have a fairly short lifetime. When an access token expires, the
refresh token can be used to obtain a new access token. Refresh token is returned as refresh token can be used to obtain a new access token. Refresh token is returned as
part of JSON response when verification code is used to obtain the access token: part of JSON response when verification code is used to obtain the access token:
[source,json] [source,json]
...@@ -122,10 +132,9 @@ $ curl 'https://sandbox.genesys-pgr.org/oauth/token?grant_type=refresh_token&cli ...@@ -122,10 +132,9 @@ $ curl 'https://sandbox.genesys-pgr.org/oauth/token?grant_type=refresh_token&cli
---- ----
== Client errors == Client errors
The API returns descriptive information in the response body about why the request failed to execute. The API returns descriptive information in the response body about why the request failed to execute.
=== 401 Unauthorized === 401 Unauthorized
...@@ -141,3 +150,9 @@ WWW-Authenticate: Bearer realm="genesys2", error="unauthorized", error_descripti ...@@ -141,3 +150,9 @@ WWW-Authenticate: Bearer realm="genesys2", error="unauthorized", error_descripti
{"error":"unauthorized","error_description":"An Authentication object was not found in the SecurityContext"} {"error":"unauthorized","error_description":"An Authentication object was not found in the SecurityContext"}
---- ----
[bibliography]
- [[[doi]]] https://en.wikipedia.org
https://en.wikipedia.org/wiki/Digital_object_identifier[Digital object identifier].
- [[[oauth]]] A Bilbie
https://alexbilbie.com/guide-to-oauth-2-grants/[A Guide To OAuth 2.0 Grants].
package org.genesys2.hazelcast;
import java.io.IOException;
import org.genesys2.spring.config.SpringProperties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.ActiveProfiles;
import com.hazelcast.config.Config;
import com.hazelcast.config.GroupConfig;
import com.hazelcast.config.JoinConfig;
import com.hazelcast.config.NetworkConfig;
import com.hazelcast.config.TcpIpConfig;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.ManagedContext;
import com.hazelcast.spring.context.SpringManagedContext;
public class HazelcastRunner {
@Configuration
@ActiveProfiles("dev")
@Import({ SpringProperties.class })
public static class AppConfig {
protected int hazelPort=5702;
@Value("${hazelcast.instanceName}")
protected String instanceName = "genesys";
@Value("${hazelcast.password}")
protected String password;
@Value("${hazelcast.name}")
protected String name;
@Bean
public Long number() {
return new Long(13);
}
@Bean
public ManagedContext managedContext() {
return new SpringManagedContext();
}
@Bean
public HazelcastInstance hazelcast(ManagedContext managedContext) {
Config cfg = new Config();
cfg.setManagedContext(managedContext);
cfg.setInstanceName(instanceName);
GroupConfig groupConfig = cfg.getGroupConfig();
groupConfig.setName(name);
groupConfig.setPassword(password);
cfg.setProperty("hazelcast.merge.first.run.delay.seconds", "5");
cfg.setProperty("hazelcast.merge.next.run.delay.seconds", "5");
cfg.setProperty("hazelcast.logging.type", "log4j");
cfg.setProperty("hazelcast.icmp.enabled", "true");
NetworkConfig network = cfg.getNetworkConfig();
network.setPort(hazelPort);
network.setPortAutoIncrement(true);
JoinConfig join = network.getJoin();
join.getMulticastConfig().setEnabled(false);
TcpIpConfig tcpIpConfig = join.getTcpIpConfig();
tcpIpConfig.setEnabled(true);
tcpIpConfig.setConnectionTimeoutSeconds(20);
// See if there's a local HZ running
tcpIpConfig.addMember("127.0.0.1:5701");
HazelcastInstance instance = Hazelcast.newHazelcastInstance(cfg);
return instance;
}
}
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class);
HazelcastInstance instance = ctx.getBean(HazelcastInstance.class);
System.out.println(instance);
System.out.println("Press any key to quit.");
try {
System.in.read();
} catch (IOException e) {
}
ctx.close();
}
}
...@@ -50,7 +50,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; ...@@ -50,7 +50,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration @Configuration
@PropertySource("classpath:/spring/spring.properties") @PropertySource("classpath:/spring/spring.properties")
@EnableJpaRepositories(basePackages = { "org.genesys.blocks.persistence", "org.genesys.blocks.security.persistence", "org.genesys.filerepository.persistence", "org.genesys2.server.persistence.acl", "org.genesys2.server.persistence.domain", @EnableJpaRepositories(basePackages = { "org.genesys.blocks.persistence", "org.genesys.blocks.security.persistence","org.genesys.blocks.oauth.persistence", "org.genesys.filerepository.persistence", "org.genesys2.server.persistence.acl", "org.genesys2.server.persistence.domain",
"org.genesys2.server.filerepository.persistence" }, repositoryImplementationPostfix = "CustomImpl", entityManagerFactoryRef = "entityManagerFactory", transactionManagerRef = "transactionManager") "org.genesys2.server.filerepository.persistence" }, repositoryImplementationPostfix = "CustomImpl", entityManagerFactoryRef = "entityManagerFactory", transactionManagerRef = "transactionManager")
@EnableTransactionManagement @EnableTransactionManagement
public class JpaDataConfig { public class JpaDataConfig {
...@@ -80,7 +80,7 @@ public class JpaDataConfig { ...@@ -80,7 +80,7 @@ public class JpaDataConfig {
bean.setDataSource(dataSource()); bean.setDataSource(dataSource());
bean.setPersistenceUnitName("spring-jpa"); bean.setPersistenceUnitName("spring-jpa");
bean.setPackagesToScan("org.genesys.blocks.model", "org.genesys.blocks.security.model", "org.genesys2.server.model", "org.genesys.filerepository.model"); bean.setPackagesToScan("org.genesys.blocks.model", "org.genesys.blocks.security.model", "org.genesys.blocks.oauth.model", "org.genesys2.server.model", "org.genesys.filerepository.model");
bean.setPersistenceProvider(new HibernatePersistenceProvider()); bean.setPersistenceProvider(new HibernatePersistenceProvider());
final HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter(); final HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
......
...@@ -26,6 +26,11 @@ import com.hazelcast.core.IQueue; ...@@ -26,6 +26,11 @@ import com.hazelcast.core.IQueue;
import org.apache.velocity.app.VelocityEngine; import org.apache.velocity.app.VelocityEngine;
import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.collect.Sets;
import org.genesys.blocks.oauth.persistence.AccessTokenRepository;
import org.genesys.blocks.oauth.persistence.OAuthClientRepository;
import org.genesys.blocks.oauth.persistence.RefreshTokenRepository;
import org.genesys.blocks.oauth.service.OAuthClientDetailsService;
import org.genesys.blocks.oauth.service.OAuthServiceImpl;
import org.genesys.blocks.security.persistence.AclClassPersistence; import org.genesys.blocks.security.persistence.AclClassPersistence;
import org.genesys.blocks.security.persistence.AclEntryPersistence; import org.genesys.blocks.security.persistence.AclEntryPersistence;
import org.genesys.blocks.security.persistence.AclObjectIdentityPersistence; import org.genesys.blocks.security.persistence.AclObjectIdentityPersistence;
...@@ -61,9 +66,6 @@ import org.genesys2.server.persistence.domain.MaterialSubRequestRepository; ...@@ -61,9 +66,6 @@ import org.genesys2.server.persistence.domain.MaterialSubRequestRepository;
import org.genesys2.server.persistence.domain.MetadataMethodRepository; import org.genesys2.server.persistence.domain.MetadataMethodRepository;
import org.genesys2.server.persistence.domain.MetadataRepository; import org.genesys2.server.persistence.domain.MetadataRepository;
import org.genesys2.server.persistence.domain.MethodRepository; import org.genesys2.server.persistence.domain.MethodRepository;
import org.genesys2.server.persistence.domain.OAuthAccessTokenPersistence;
import org.genesys2.server.persistence.domain.OAuthClientDetailsPersistence;
import org.genesys2.server.persistence.domain.OAuthRefreshTokenPersistence;
import org.genesys2.server.persistence.domain.OrganizationRepository; import org.genesys2.server.persistence.domain.OrganizationRepository;
import org.genesys2.server.persistence.domain.ParameterCategoryRepository; import org.genesys2.server.persistence.domain.ParameterCategoryRepository;
import org.genesys2.server.persistence.domain.ParameterRepository; import org.genesys2.server.persistence.domain.ParameterRepository;
...@@ -92,10 +94,8 @@ import org.genesys2.server.service.GeoService; ...@@ -92,10 +94,8 @@ import org.genesys2.server.service.GeoService;
import org.genesys2.server.service.HtmlSanitizer; import org.genesys2.server.service.HtmlSanitizer;
import org.genesys2.server.service.InstituteFilesService; import org.genesys2.server.service.InstituteFilesService;
import org.genesys2.server.service.InstituteService; import org.genesys2.server.service.InstituteService;
import org.genesys2.server.service.JPATokenStore;
import org.genesys2.server.service.KPIService; import org.genesys2.server.service.KPIService;
import org.genesys2.server.service.MappingService; import org.genesys2.server.service.MappingService;
import org.genesys2.server.service.OAuth2ClientDetailsService;
import org.genesys2.server.service.OrganizationService; import org.genesys2.server.service.OrganizationService;
import org.genesys2.server.service.RequestService; import org.genesys2.server.service.RequestService;
import org.genesys2.server.service.TaxonomyService; import org.genesys2.server.service.TaxonomyService;
...@@ -121,8 +121,6 @@ import org.genesys2.server.service.impl.InstituteFilesServiceImpl; ...@@ -121,8 +121,6 @@ import org.genesys2.server.service.impl.InstituteFilesServiceImpl;
import org.genesys2.server.service.impl.InstituteServiceImpl; import org.genesys2.server.service.impl.InstituteServiceImpl;
import org.genesys2.server.service.impl.KPIServiceImpl; import org.genesys2.server.service.impl.KPIServiceImpl;
import org.genesys2.server.service.impl.MappingServiceImpl; import org.genesys2.server.service.impl.MappingServiceImpl;
import org.genesys2.server.service.impl.OAuth2ClientDetailsServiceImpl;
import org.genesys2.server.service.impl.OAuth2JPATokenStoreImpl;
import org.genesys2.server.service.impl.OWASPSanitizer; import org.genesys2.server.service.impl.OWASPSanitizer;
import org.genesys2.server.service.impl.OrganizationServiceImpl; import org.genesys2.server.service.impl.OrganizationServiceImpl;
import org.genesys2.server.service.impl.RequestServiceImpl; import org.genesys2.server.service.impl.RequestServiceImpl;
...@@ -133,6 +131,7 @@ import org.genesys2.server.service.impl.TokenVerificationServiceImpl; ...@@ -133,6 +131,7 @@ import org.genesys2.server.service.impl.TokenVerificationServiceImpl;
import org.genesys2.server.service.impl.UserServiceImpl; import org.genesys2.server.service.impl.UserServiceImpl;
import org.genesys2.server.service.worker.ElasticUpdater; import org.genesys2.server.service.worker.ElasticUpdater;
import org.genesys2.server.service.worker.GeoRegionDataCLDR; import org.genesys2.server.service.worker.GeoRegionDataCLDR;
import org.genesys2.server.servlet.controller.admin.OAuthManagementController;
import org.genesys2.server.servlet.controller.rest.AccessionController; import org.genesys2.server.servlet.controller.rest.AccessionController;
import org.genesys2.server.servlet.controller.rest.CacheController; import org.genesys2.server.servlet.controller.rest.CacheController;
import org.genesys2.server.servlet.controller.rest.CropsController; import org.genesys2.server.servlet.controller.rest.CropsController;
...@@ -140,11 +139,9 @@ import org.genesys2.server.servlet.controller.rest.DatasetController; ...@@ -140,11 +139,9 @@ import org.genesys2.server.servlet.controller.rest.DatasetController;
import org.genesys2.server.servlet.controller.rest.InstituteGalleriesController; import org.genesys2.server.servlet.controller.rest.InstituteGalleriesController;
import org.genesys2.server.servlet.controller.rest.KPIController; import org.genesys2.server.servlet.controller.rest.KPIController;
import org.genesys2.server.servlet.controller.rest.LookupController; import org.genesys2.server.servlet.controller.rest.LookupController;
import org.genesys2.server.servlet.controller.rest.OAuthManagementController;
import org.genesys2.server.servlet.controller.rest.OrganizationController; import org.genesys2.server.servlet.controller.rest.OrganizationController;
import org.genesys2.server.servlet.controller.rest.PermissionController; import org.genesys2.server.servlet.controller.rest.PermissionController;
import org.genesys2.server.servlet.controller.rest.RequestsController; import org.genesys2.server.servlet.controller.rest.RequestsController;
import org.genesys2.server.servlet.controller.rest.TokenController;
import org.genesys2.server.servlet.controller.rest.TraitsController; import org.genesys2.server.servlet.controller.rest.TraitsController;
import org.genesys2.server.servlet.controller.rest.UserController; import org.genesys2.server.servlet.controller.rest.UserController;
import org.genesys2.server.servlet.controller.rest.UsersController; import org.genesys2.server.servlet.controller.rest.UsersController;
...@@ -165,7 +162,6 @@ import org.springframework.mail.javamail.JavaMailSender; ...@@ -165,7 +162,6 @@ import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl; import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.security.oauth2.provider.token.ConsumerTokenServices; import org.springframework.security.oauth2.provider.token.ConsumerTokenServices;
import org.springframework.security.oauth2.provider.token.DefaultTokenServices;
import org.springframework.security.oauth2.provider.token.TokenStore; import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.HierarchyMode; import org.springframework.test.annotation.DirtiesContext.HierarchyMode;
...@@ -310,10 +306,10 @@ public abstract class AbstractRestTest extends BaseSpringTest { ...@@ -310,10 +306,10 @@ public abstract class AbstractRestTest extends BaseSpringTest {
} }
@Bean @Bean
public OAuth2ClientDetailsService auth2ClientDetailsService() { public OAuthServiceImpl oauthService() {
return new OAuth2ClientDetailsServiceImpl(); return new OAuthServiceImpl();
} }
@Bean @Bean
public EMailVerificationService emailVerificationService() { public EMailVerificationService emailVerificationService() {
return new EMailVerificationServiceImpl(); return new EMailVerificationServiceImpl();
...@@ -404,23 +400,6 @@ public abstract class AbstractRestTest extends BaseSpringTest { ...@@ -404,23 +400,6 @@ public abstract class AbstractRestTest extends BaseSpringTest {
return new EasySMTAMockConnector(); return new EasySMTAMockConnector();
} }
@Bean
public TokenController tokenController() {
return new TokenController();
}
@Bean
public ConsumerTokenServices consumerTokenServices() {
DefaultTokenServices tokenServices = new DefaultTokenServices();
tokenServices.setTokenStore(tokenStore());
return tokenServices;
}
@Bean
public JPATokenStore tokenStore() {
return new OAuth2JPATokenStoreImpl();
}
@Bean @Bean
public OAuthManagementController oAuthManagementController() { public OAuthManagementController oAuthManagementController() {
return new OAuthManagementController(); return new OAuthManagementController();
...@@ -573,29 +552,20 @@ public abstract class AbstractRestTest extends BaseSpringTest { ...@@ -573,29 +552,20 @@ public abstract class AbstractRestTest extends BaseSpringTest {
// OAuthManagementController oAuthManagementController; // OAuthManagementController oAuthManagementController;
@Autowired @Autowired
protected OAuthAccessTokenPersistence accessTokenPersistence; protected AccessTokenRepository accessTokenPersistence;
@Autowired
protected OAuthRefreshTokenPersistence refreshTokenPersistence;
@Autowired @Autowired
protected OAuthClientDetailsPersistence clientDetailsPersistence; protected RefreshTokenRepository refreshTokenPersistence;
@Autowired @Autowired
protected OAuth2ClientDetailsService clientDetailsService; protected OAuthClientRepository clientDetailsPersistence;
@Autowired @Autowired
protected TokenController tokenController; protected OAuthClientDetailsService clientDetailsService;
@Autowired
protected ConsumerTokenServices tokenServices;
@Autowired @Autowired
protected TokenStore tokenStore; protected TokenStore tokenStore;
@Autowired
protected ConsumerTokenServices consumerTokenServices;
@Autowired @Autowired
protected EasySMTA easySMTAConnector; protected EasySMTA easySMTAConnector;
......
/*
* Copyright 2016 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.genesys2.tests.resttests;
import static org.hamcrest.Matchers.*;