This library provides services to communicate with Identity Store REST API.
Further information can be found on the [official wiki](https://lutece.paris.fr/support/wiki/gru-library-identitystore-v3.html).
The main service is fr.paris.lutece.plugins.identitystore.v3.web.service.IdentityService which provides methods to call Identity Store.
These methods are implemented in the rest transport fr.paris.lutece.plugins.identitystore.v3.web.rs.service.IdentityTransportRest.
It requires an implementation of fr.paris.lutece.plugins.identitystore.v3.web.service.IHttpTransportProvider to define the HTTP transport. Two implementations of this interface are provided in the library :
Both implementations require URL definition of the Identity Store service end point.
When using HttpApiManagerAccessTransport, two extra parameters are required:
First, define the bean for the HTTP transport you want to use:
Then, define the bean for the rest transport IdentityTransportRest:
Then, define the bean for the service IdentityService:
Here is an example of Spring configuration with the HTTP transport HttpAccessTransport:
<!-- library identitystore --> <!-- IHttpTransportProvider declarations --> <bean id="identitystore.httpAccessTransport" class="fr.paris.lutece.plugins.identitystore.v3.web.rs.service.HttpAccessTransport" > <property name="apiEndPointUrl"> <value>${identitydesk.identitystore.apiEndPointUrl}</value> </property> </bean> <bean id="identity.restTransport.httpAccess" class="fr.paris.lutece.plugins.identitystore.v3.web.rs.service.IdentityTransportRest"> <constructor-arg ref="identitystore.httpAccessTransport"/> </bean> <!-- IdentityService impl --> <bean id="identity.identityService" class="fr.paris.lutece.plugins.identitystore.v3.web.service.IdentityService"> <constructor-arg ref="identity.restTransport.httpAccess"/> </bean>
Here is an example of Spring configuration with the HTTP transport HttpApiManagerAccessTransport:
<!-- library identitystore --> <!-- IHttpTransportProvider declarations --> <bean id="identitystore.httpAccessTransport" class="fr.paris.lutece.plugins.identitystore.v3.web.rs.service.HttpApiManagerAccessTransport"> <property name="apiEndPointUrl"> <value>${myplugin.identitystore.ApiEndPointUrl}</value> </property> <property name="accessManagerEndPointUrl"> <value>${myplugin.identitystore.accessManagerEndPointUrl}</value> </property> <property name="accessManagerCredentials"> <value>${myplugin.identitystore.accessManagerCredentials}</value> </property> </bean> <bean id="identity.restTransport.httpAccess" class="fr.paris.lutece.plugins.identitystore.v3.web.rs.service.IdentityTransportRest"> <constructor-arg ref="identitystore.httpAccessTransport"/> </bean> <!-- IdentityService impl --> <bean id="identity.identityService" class="fr.paris.lutece.plugins.identitystore.v3.web.service.IdentityService"> <constructor-arg ref="identity.restTransport.httpAccess"/> </bean>
You can finally access your bean in the java code as follows:
import fr.paris.lutece.plugins.identitystore.v3.web.service.IdentityService; ... private IdentityService _identityService = SpringContextService.getBean( "identity.identityService" );
The service can directly be created in the Java code. Here is an example with the HTTP transport HttpApiManagerAccessTransport (the same mechanism can be applied for the HTTP transport HttpAccessTransport).
First, define the following keys in a properties file:
myplugin.identitystore.ApiEndPointUrl=http://mydomain.com/url/to/apimanager/api/identitystore myplugin.identitystore.accessManagerEndPointUrl=http://mydomain.com/url/to/apimanager/token myplugin.identitystore.accessManagerCredentials=your_private_key
Then, add the following code in the Java code:
... private static final String PROPERTY_GRU_API_ENDPOINT = "myplugin.identitystore.ApiEndPointUrl"; private static final String PROPERTY_GRU_AM_ENDPOINT = "myplugin.identitystore.accessManagerEndPointUrl"; private static final String PROPERTY_GRU_AM_CREDENTIALS = "myplugin.identitystore.accessManagerCredentials"; ... HttpApiManagerAccessTransport httpApiManagerAccessTransport = new HttpApiManagerAccessTransport( ) httpApiManagerAccessTransport.setApiEndPointUrl( AppPropertiesService.getProperty( PROPERTY_GRU_API_ENDPOINT ) ); httpApiManagerAccessTransport.setAccessManagerEndPointUrl( AppPropertiesService.getProperty( PROPERTY_GRU_AM_ENDPOINT ) ); httpApiManagerAccessTransport.setAccessManagerCredentials( AppPropertiesService.getProperty( PROPERTY_GRU_AM_CREDENTIALS ) ); IdentityTransportRest identityTransport = new IdentityTransportRest( httpApiManagerAccessTransport ); final IdentityService identityService = new IdentityService( identityTransport ); ...