Class AbstractAuthenticationProvider
- java.lang.Object
-
- net.webpdf.wsclient.session.auth.AbstractAuthenticationProvider
-
- All Implemented Interfaces:
AuthProvider
- Direct Known Subclasses:
AnonymousAuthProvider,UserAuthProvider
public abstract class AbstractAuthenticationProvider extends Object implements AuthProvider
A class extending
AbstractAuthenticationProvidershall provide the means to use the webPDF server´s login endpoint to authenticate a user. It shall also organize the automatic refresh of theSessionTokenprovided by the login endpoint and shall update it´s usedAuthMaterialaccordingly.Be aware: Currently an
AbstractAuthenticationProvidershall only serve oneSessionat a time. AnAbstractAuthenticationProviderbeing called by anotherSessionthan it´s current master, shall assume it´s current master to have expired and shall, try to reauthorize that newSession(new master).
For that reason anAbstractAuthenticationProviders shall be reusable by subsequentSessions.Be aware: However - An implementation of
AuthProvideris not required to serve multipleSessions at a time. It is expected to create a newAuthProviderfor each existingSession.
-
-
Constructor Summary
Constructors Constructor Description AbstractAuthenticationProvider(@NotNull AuthMaterial authMaterial)Creates a fresh authentication provider, that shall initialize aSessionusing the givenAuthMaterial.
Be aware: possibly the givenAuthMaterialwill only be used during login and will be replaced with aSessionToken.AbstractAuthenticationProvider(@NotNull AuthMaterial authMaterial, AuthMaterial resumeAuthMaterial)Resumes an existing authentication provider, that shall resume aSessionif aSessionTokenis provided.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected @NotNull AuthMaterialgetAuthMaterial()Returns the currently usedAuthMaterial.@NotNull AuthMaterialgetInitialAuthMaterial()Returns the initialAuthMaterialgiven to thisAuthProvider.@Nullable SessiongetSession()Returns the currentSessionthisAuthProviderprovides authorization for.protected @NotNull AuthMateriallogin(@NotNull Session session)Login and provide authorizationSessionTokenfor aSession.@NotNull AuthMaterialprovide(@NotNull Session session)ProvidesAuthMaterialfor the authorization of aSession.
Will attempt to produce aSessionTokenforRestSessions.
Will also refresh expiredSessionTokens.@NotNull AuthMaterialrefresh(Session session)Refresh authorizationSessionTokenfor an activeSession.protected voidsetAuthMaterial(@NotNull AuthMaterial authMaterial)Sets the usedAuthMaterial.
-
-
-
Constructor Detail
-
AbstractAuthenticationProvider
public AbstractAuthenticationProvider(@NotNull @NotNull AuthMaterial authMaterial)Creates a fresh authentication provider, that shall initialize a
Sessionusing the givenAuthMaterial.
Be aware: possibly the givenAuthMaterialwill only be used during login and will be replaced with aSessionToken.Be aware: Currently an
AbstractAuthenticationProvidershall only serve oneSessionat a time. AnAbstractAuthenticationProviderbeing called by anotherSessionthan it´s current master, shall assume it´s current master to have expired and shall, try to reauthorize that newSession(new master).
For that reason anAbstractAuthenticationProviders shall be reusable by subsequentSessions.- Parameters:
authMaterial- TheAuthMaterialto initialize theSessionwith.
-
AbstractAuthenticationProvider
public AbstractAuthenticationProvider(@NotNull @NotNull AuthMaterial authMaterial, AuthMaterial resumeAuthMaterial)Resumes an existing authentication provider, that shall resume a
Sessionif aSessionTokenis provided.Be aware: Currently an
AbstractAuthenticationProvidershall only serve oneSessionat a time. AnAbstractAuthenticationProviderbeing called by anotherSessionthan it´s current master, shall assume it´s current master to have expired and shall, try to reauthorize that newSession(new master).
For that reason anAbstractAuthenticationProviders shall be reusable by subsequentSessions.- Parameters:
authMaterial- TheAuthMaterialto initialize theSessionwith.resumeAuthMaterial- TheAuthMaterialto resume theSessionwith.
-
-
Method Detail
-
getSession
@Nullable public @Nullable Session getSession()
Returns the currentSessionthisAuthProviderprovides authorization for.- Returns:
- The current
SessionthisAuthProviderprovides authorization for.
-
getInitialAuthMaterial
@NotNull public @NotNull AuthMaterial getInitialAuthMaterial()
Returns the initialAuthMaterialgiven to thisAuthProvider.- Returns:
- The initial
AuthMaterialgiven to thisAuthProvider.
-
getAuthMaterial
@NotNull protected @NotNull AuthMaterial getAuthMaterial()
Returns the currently usedAuthMaterial.- Returns:
- The currently used
AuthMaterial.
-
setAuthMaterial
protected void setAuthMaterial(@NotNull @NotNull AuthMaterial authMaterial)Sets the usedAuthMaterial.- Parameters:
authMaterial- TheAuthMaterialto set.
-
refresh
@NotNull public @NotNull AuthMaterial refresh(Session session) throws AuthResultException
Refresh authorizationSessionTokenfor an activeSession.- Specified by:
refreshin interfaceAuthProvider- Parameters:
session- The session to refresh the authorization for.- Returns:
- The
AuthMaterialrefreshed by thisAuthProvider. - Throws:
AuthResultException- Shall be thrown, should the authentication/authorization fail for some reason.
-
login
@NotNull protected @NotNull AuthMaterial login(@NotNull @NotNull Session session) throws AuthResultException
Login and provide authorizationSessionTokenfor aSession.- Parameters:
session- The session to provide the authorization for.- Returns:
- The
AuthMaterialprovided by thisAuthProvider. - Throws:
AuthResultException- Shall be thrown, should the authentication/authorization fail for some reason.
-
provide
@NotNull public @NotNull AuthMaterial provide(@NotNull @NotNull Session session) throws AuthResultException
Provides
AuthMaterialfor the authorization of aSession.
Will attempt to produce aSessionTokenforRestSessions.
Will also refresh expiredSessionTokens.Be aware: Currently an
AbstractAuthenticationProvidershall only serve oneSessionat a time. AnAbstractAuthenticationProviderbeing called by anotherSessionthan it´s current master, shall assume it´s current master to have expired and shall, try to reauthorize that newSession(new master).
For that reason anAbstractAuthenticationProviders shall be reusable by subsequentSessions.- Specified by:
providein interfaceAuthProvider- Parameters:
session- The session to provide authorization for.- Returns:
- The
AuthMaterialprovided by thisAuthProvider. - Throws:
AuthResultException- Shall be thrown, should the authentication/authorization fail for some reason.
-
-