Package org.saidone.restless.client
Class AuthenticationServiceClient
java.lang.Object
org.saidone.restless.client.AuthenticationServiceClient
- All Implemented Interfaces:
TicketProvider
Manages Alfresco repository tickets through the gRPC authentication service. Credential exchange
requires no existing ticket. Validation and revocation send the supplied ticket in call metadata.
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.restless.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 ticket in the repository and clears the local cache if it holds that ticket.ticket()Returns the cached ticket, logging in with the credentials of the constructor if there is none.validateTicket(String ticket) Validates a ticket without trying another ticket if the repository rejects it.
-
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.restless.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
-
-
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 a ticket without trying another ticket if the repository rejects it.- Parameters:
ticket- ticket to validate- Returns:
- the validated ticket identifier
-
invalidateTicket
Revokes the supplied ticket in the repository and clears the local cache if it holds that ticket.- Parameters:
ticket- ticket to revoke
-
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
-