Class AuthenticationServiceClient

java.lang.Object
org.saidone.restless.client.AuthenticationServiceClient
All Implemented Interfaces:
TicketProvider

public class AuthenticationServiceClient extends Object implements 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 Details

    • AuthenticationServiceClient

      public AuthenticationServiceClient(io.grpc.Channel channel, 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 caller
      deadline - 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 caller
      user - Alfresco username used for authentication
      password - password for the supplied username
      deadline - 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 service
      deadline - per-call deadline applied to every RPC attempt
  • Method Details

    • authenticate

      public String authenticate(String user, String password)
      Exchanges user and password for a new ticket. Wrong credentials are UNAUTHENTICATED.
      Parameters:
      user - Alfresco username used for authentication
      password - password for the supplied username
      Returns:
      the authenticated repository ticket
    • validateTicket

      public String validateTicket(String ticket)
      Validates a ticket without trying another ticket if the repository rejects it.
      Parameters:
      ticket - ticket to validate
      Returns:
      the validated ticket identifier
    • invalidateTicket

      public void invalidateTicket(String ticket)
      Revokes the supplied ticket in the repository and clears the local cache if it holds that ticket.
      Parameters:
      ticket - ticket to revoke
    • ticket

      public String ticket()
      Returns the cached ticket, logging in with the credentials of the constructor if there is none.
      Specified by:
      ticket in interface TicketProvider
      Returns:
      the authenticated repository ticket
    • invalidate

      public void invalidate(String expired)
      Drops expired so that the next ticket() call logs in again.
      Specified by:
      invalidate in interface TicketProvider
      Parameters:
      expired - ticket rejected by a server call; only the matching cached ticket is invalidated