Package org.saidone.unrest.client
Class AuthenticationServiceClient
java.lang.Object
org.saidone.unrest.client.AuthenticationServiceClient
- All Implemented Interfaces:
TicketProvider
Client of the AuthenticationService of the gRPC module: exchanges user and password for an Alfresco ticket,
gRPC only, no REST. Authenticate sends no ticket header: it is the only call that needs none.
Built with credentials it is also the TicketProvider shared by the repository service clients: it logs in lazily,
on the first ticket(), caches the ticket and logs in again after invalidate(java.lang.String). Wrong credentials
surface as the StatusRuntimeException of the server (UNAUTHENTICATED).
val tickets = new AuthenticationServiceClient(channel, "mcp", "secret", Duration.ofSeconds(30));
val client = new NodeServiceClient(channel, tickets, Duration.ofSeconds(30));
-
Constructor Summary
ConstructorsConstructorDescriptionAuthenticationServiceClient(io.grpc.Channel channel, String user, String password, Duration deadline) Creates this service client with shared authentication and a per-call deadline.AuthenticationServiceClient(io.grpc.Channel channel, Duration deadline) Creates this service client with shared authentication and a per-call deadline.AuthenticationServiceClient(org.saidone.unrest.api.AuthenticationServiceGrpc.AuthenticationServiceBlockingStub stub, String user, String password, Duration deadline) Creates this service client with shared authentication and a per-call deadline.AuthenticationServiceClient(org.saidone.unrest.api.AuthenticationServiceGrpc.AuthenticationServiceBlockingStub stub, Duration deadline) Creates this service client with shared authentication and a per-call deadline. -
Method Summary
Modifier and TypeMethodDescriptionauthenticate(String user, String password) Exchanges user and password for a new ticket.voidinvalidate(String expired) Dropsexpiredso that the nextticket()call logs in again.voidinvalidateTicket(String ticket) Revokes the supplied Alfresco ticket in the repository.ticket()Returns the cached ticket, logging in with the credentials of the constructor if there is none.validateTicket(String ticket) Validates the supplied Alfresco ticket and returns its identifier.
-
Constructor Details
-
AuthenticationServiceClient
Creates this service client with shared authentication and a per-call deadline.The caller retains ownership of the channel; closing an application should close its shared channel once.
- Parameters:
channel- shared gRPC channel; ownership remains with the callerdeadline- per-call deadline applied to every RPC attempt
-
AuthenticationServiceClient
public AuthenticationServiceClient(io.grpc.Channel channel, String user, String password, Duration deadline) Creates this service client with shared authentication and a per-call deadline.The caller retains ownership of the channel; closing an application should close its shared channel once.
- Parameters:
channel- shared gRPC channel; ownership remains with the calleruser- Alfresco username used for authenticationpassword- password for the supplied usernamedeadline- per-call deadline applied to every RPC attempt
-
AuthenticationServiceClient
public AuthenticationServiceClient(org.saidone.unrest.api.AuthenticationServiceGrpc.AuthenticationServiceBlockingStub stub, Duration deadline) Creates this service client with shared authentication and a per-call deadline.The caller retains ownership of the channel; closing an application should close its shared channel once.
- Parameters:
stub- preconfigured stub for this repository servicedeadline- per-call deadline applied to every RPC attempt
-
AuthenticationServiceClient
public AuthenticationServiceClient(org.saidone.unrest.api.AuthenticationServiceGrpc.AuthenticationServiceBlockingStub stub, String user, String password, Duration deadline) Creates this service client with shared authentication and a per-call deadline.The caller retains ownership of the channel; closing an application should close its shared channel once.
- Parameters:
stub- preconfigured stub for this repository serviceuser- Alfresco username used for authenticationpassword- password for the supplied usernamedeadline- per-call deadline applied to every RPC attempt
-
-
Method Details
-
authenticate
Exchanges user and password for a new ticket. Wrong credentials are UNAUTHENTICATED.- Parameters:
user- Alfresco username used for authenticationpassword- password for the supplied username- Returns:
- the authenticated repository ticket
-
validateTicket
Validates the supplied Alfresco ticket and returns its identifier. -
invalidateTicket
Revokes the supplied Alfresco ticket in the repository. -
ticket
Returns the cached ticket, logging in with the credentials of the constructor if there is none.- Specified by:
ticketin interfaceTicketProvider- Returns:
- the authenticated repository ticket
-
invalidate
Dropsexpiredso that the nextticket()call logs in again.- Specified by:
invalidatein interfaceTicketProvider- Parameters:
expired- ticket rejected by a server call; only the matching cached ticket is invalidated
-