Class OpenIdConnectAuthenticator

java.lang.Object
org.codelibs.fess.sso.oic.OpenIdConnectAuthenticator
All Implemented Interfaces:
SsoAuthenticator

public class OpenIdConnectAuthenticator extends Object implements SsoAuthenticator
OpenID Connect authenticator for SSO integration.
  • Field Details

    • OIC_AUTH_SERVER_url

      protected static final String OIC_AUTH_SERVER_url
      Configuration key for OpenID Connect authorization server url.
      See Also:
    • OIC_CLIENT_ID

      protected static final String OIC_CLIENT_ID
      Configuration key for OpenID Connect client ID.
      See Also:
    • OIC_SCOPE

      protected static final String OIC_SCOPE
      Configuration key for OpenID Connect scope.
      See Also:
    • OIC_REDIRECT_url

      protected static final String OIC_REDIRECT_url
      Configuration key for OpenID Connect redirect url.
      See Also:
    • OIC_TOKEN_SERVER_url

      protected static final String OIC_TOKEN_SERVER_url
      Configuration key for OpenID Connect token server url.
      See Also:
    • OIC_CLIENT_SECRET

      protected static final String OIC_CLIENT_SECRET
      Configuration key for OpenID Connect client secret.
      See Also:
    • OIC_STATE

      protected static final String OIC_STATE
      Session key for OpenID Connect state parameter.
      See Also:
    • OIC_BASE_url

      protected static final String OIC_BASE_url
      Configuration key for OpenID Connect base url.
      See Also:
    • httpTransport

      protected final com.google.api.client.http.HttpTransport httpTransport
      HTTP transport for OpenID Connect requests.
    • jsonFactory

      protected final com.google.api.client.json.JsonFactory jsonFactory
      JSON factory for OpenID Connect response parsing.
  • Constructor Details

    • OpenIdConnectAuthenticator

      public OpenIdConnectAuthenticator()
      Default constructor.
  • Method Details

    • init

      @PostConstruct public void init()
      Initializes the OpenID Connect authenticator.
    • getLoginCredential

      public org.lastaflute.web.login.credential.LoginCredential getLoginCredential()
      Description copied from interface: SsoAuthenticator
      Gets the login credential for SSO authentication.
      Specified by:
      getLoginCredential in interface SsoAuthenticator
      Returns:
      The login credential.
    • getAuthurl

      protected String getAuthurl(jakarta.servlet.http.HttpServletRequest request)
      Gets the authorization url for OpenID Connect.
      Parameters:
      request - the HTTP servlet request
      Returns:
      the authorization url
    • decodeBase64

      protected byte[] decodeBase64(String base64String)
      Decodes a Base64 string to bytes.
      Parameters:
      base64String - the Base64 string to decode
      Returns:
      the decoded bytes, or null if input is null
    • processCallback

      protected org.lastaflute.web.login.credential.LoginCredential processCallback(jakarta.servlet.http.HttpServletRequest request, String code)
      Processes the callback from OpenID Connect provider.
      Parameters:
      request - the HTTP servlet request
      code - the authorization code
      Returns:
      the login credential
    • parseJwtClaim

      protected void parseJwtClaim(String jwtClaim, Map<String,Object> attributes) throws IOException
      Parses the JWT claim and extracts attributes.
      Parameters:
      jwtClaim - the JWT claim string
      attributes - the attributes map to populate
      Throws:
      IOException - if an I/O error occurs
    • parsePrimitive

      protected Object parsePrimitive(com.google.api.client.json.JsonParser jsonParser) throws IOException
      Parses primitive values from JSON parser.
      Parameters:
      jsonParser - the JSON parser
      Returns:
      the parsed primitive value
      Throws:
      IOException - if an I/O error occurs
    • parseArray

      protected Object parseArray(com.google.api.client.json.JsonParser jsonParser) throws IOException
      Parses array values from JSON parser.
      Parameters:
      jsonParser - the JSON parser
      Returns:
      the parsed array as a list
      Throws:
      IOException - if an I/O error occurs
    • parseObject

      protected Map<String,Object> parseObject(com.google.api.client.json.JsonParser jsonParser) throws IOException
      Parses object values from JSON parser.
      Parameters:
      jsonParser - the JSON parser
      Returns:
      the parsed object as a map
      Throws:
      IOException - if an I/O error occurs
    • getTokenurl

      protected com.google.api.client.auth.oauth2.TokenResponse getTokenurl(String code) throws IOException
      Gets the token response from the OpenID Connect provider.
      Parameters:
      code - the authorization code
      Returns:
      the token response
      Throws:
      IOException - if an I/O error occurs
    • getOicClientSecret

      protected String getOicClientSecret()
      Gets the OpenID Connect client secret.
      Returns:
      the client secret
    • getOicTokenServerurl

      protected String getOicTokenServerurl()
      Gets the OpenID Connect token server url.
      Returns:
      the token server url
    • getOicRedirecturl

      protected String getOicRedirecturl()
      Gets the OpenID Connect redirect url.
      Returns:
      the redirect url
    • buildDefaultRedirecturl

      protected String buildDefaultRedirecturl()
      Builds a default redirect url for OpenID Connect based on the environment. Uses the configured base url or defaults to http://localhost:8080 for compatibility with common OIDC provider configurations.
      Returns:
      the default redirect url
    • getOicScope

      protected String getOicScope()
      Gets the OpenID Connect scope.
      Returns:
      the scope
    • getOicClientId

      protected String getOicClientId()
      Gets the OpenID Connect client ID.
      Returns:
      the client ID
    • getOicAuthServerurl

      protected String getOicAuthServerurl()
      Gets the OpenID Connect authorization server url.
      Returns:
      the authorization server url
    • resolveCredential

      public void resolveCredential(FessLoginAssist.LoginCredentialResolver resolver)
      Description copied from interface: SsoAuthenticator
      Resolves credential using the provided resolver.
      Specified by:
      resolveCredential in interface SsoAuthenticator
      Parameters:
      resolver - The login credential resolver.
    • getResponse

      public org.lastaflute.web.response.ActionResponse getResponse(SsoResponseType responseType)
      Description copied from interface: SsoAuthenticator
      Gets the action response for the specified SSO response type.
      Specified by:
      getResponse in interface SsoAuthenticator
      Parameters:
      responseType - The type of SSO response required.
      Returns:
      The action response.
    • logout

      public String logout(org.codelibs.fess.mylasta.action.FessUserBean user)
      Description copied from interface: SsoAuthenticator
      Performs logout for the specified user.
      Specified by:
      logout in interface SsoAuthenticator
      Parameters:
      user - The user to logout.
      Returns:
      The logout url or null if not applicable.