Class AuthenticationResource
- java.lang.Object
-
- org.silverpeas.core.web.rs.RESTWebService
-
- org.silverpeas.core.webapi.profile.AuthenticationResource
-
- All Implemented Interfaces:
ProtectedWebResource
,WebAuthenticationValidation
,WebAuthorizationValidation
,SilverpeasWebResource
@WebService @Path("authentication") public class AuthenticationResource extends RESTWebService
A REST-based Web service to authenticate a user in Silverpeas.If the authentication matches the
Basic
authentication scheme, then a session is opened in Silverpeas for the user behind the request and this session can be used both for browsing the Silverpeas web portal or to access the REST API by the same client. If the authentication matches aBearer
authentication scheme, then a session is created just for the HTTP request. Latter is hence pertinent only to check the the user can access the REST API of Silverpeas.This service is only interesting for opening an HTTP session before performing several tasks in Silverpeas. It avoids to authenticate the user by its login and password for each HTTP request against the REST API of Silverpeas. Nevertheless, the recommended (and better) way to consume the REST API is to use the Bearer authentication scheme with the API token of the user; the token can be passed in each request against the REST API in the
Authorization
HTTP header without passing through the heaver authentication mechanism by user credentials (login/domain/password).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.silverpeas.core.web.rs.RESTWebService
RESTWebService.WebProcess<R>, RESTWebService.WebTreatment<R>
-
-
Field Summary
-
Fields inherited from class org.silverpeas.core.web.rs.RESTWebService
RESPONSE_HEADER_ARRAYSIZE
-
Fields inherited from interface org.silverpeas.core.web.SilverpeasWebResource
BASE_PATH
-
-
Constructor Summary
Constructors Constructor Description AuthenticationResource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UserProfileEntity
authenticate()
Authenticates the user from his credentials passed through theAuthorization
HTTP header, opens a new HTTP session in Silverpeas in the case of a Basic authentication scheme, or throws aWebApplicationException
exception.String
getComponentId()
Gets the identifier of the component instance to which the requested resource belongs to.protected String
getResourceBasePath()
Gets the base path of the web resource relative to the root path of all the web resources in Silverpeas as given bySilverpeasWebResource.getBasePath()
.-
Methods inherited from class org.silverpeas.core.web.rs.RESTWebService
createWebResourceUri, fromPage, getBundle, getBundleLocation, getHighestUserRole, getHttpRequest, getHttpServletRequest, getHttpServletResponse, getOrganisationController, getSilverpeasContext, getUri, getUser, getUserPreferences, getUserRoles, identifiedBy, identifiedBy, initContext, initWebResourceUri, isUserDefined, process
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.silverpeas.core.web.rs.ProtectedWebResource
validateUserAuthorization
-
Methods inherited from interface org.silverpeas.core.web.rs.WebAuthenticationValidation
validateUserAuthentication
-
-
-
-
Method Detail
-
authenticate
@POST @Produces("application/json") public UserProfileEntity authenticate()
Authenticates the user from his credentials passed through theAuthorization
HTTP header, opens a new HTTP session in Silverpeas in the case of a Basic authentication scheme, or throws aWebApplicationException
exception. If the user has already opened a session in Silverpeas and the request carries the session identifier, then nothing is done.- Returns:
- The profile of the user once authenticated.
-
getResourceBasePath
protected String getResourceBasePath()
Description copied from class:RESTWebService
Gets the base path of the web resource relative to the root path of all the web resources in Silverpeas as given bySilverpeasWebResource.getBasePath()
.- Specified by:
getResourceBasePath
in classRESTWebService
- Returns:
- the relative path that identifies this REST web service among all other REST web services.
-
getComponentId
public String getComponentId()
Description copied from interface:SilverpeasWebResource
Gets the identifier of the component instance to which the requested resource belongs to.- Returns:
- the identifier of the Silverpeas component instance.
-
-