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.