org.keycloak.protocol.oidc.utils

## Class OAuth2CodeParser

- java.lang.Object
- - org.keycloak.protocol.oidc.utils.OAuth2CodeParser

-     public class OAuth2CodeParser
      extends Object

  Author:
    Marek Posolda

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `OAuth2CodeParser.ParseResult`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `OAuth2CodeParser()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static OAuth2CodeParser.ParseResult` | `parseCode(KeycloakSession session, String code, RealmModel realm, EventBuilder event)` Will parse the code and retrieve the corresponding OAuth2Code and AuthenticatedClientSessionModel.
    `static String` | `persistCode(KeycloakSession session, AuthenticatedClientSessionModel clientSession, OAuth2Code codeData)` Will persist the code to the cache and return the object with the codeData and code correctly set

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### OAuth2CodeParser

          public OAuth2CodeParser()

  - ### Method Detail

    - #### persistCode

          public static String persistCode(KeycloakSession session,
                                           AuthenticatedClientSessionModel clientSession,
                                           OAuth2Code codeData)

      Will persist the code to the cache and return the object with the codeData and code correctly set
      Parameters:
        `session` -
        `clientSession` -
        `codeData` -
      Returns:
        code parameter to be used in OAuth2 handshake

    - #### parseCode

          public static OAuth2CodeParser.ParseResult parseCode(KeycloakSession session,
                                                               String code,
                                                               RealmModel realm,
                                                               EventBuilder event)

      Will parse the code and retrieve the corresponding OAuth2Code and AuthenticatedClientSessionModel. Will also check if code wasn't already used and if it wasn't expired. If it was already used (or other error happened during parsing), then returned parser will have "isIllegalHash" set to true. If it was expired, the parser will have "isExpired" set to true
      Parameters:
        `session` -
        `code` -
        `realm` -
        `event` -
      Returns:

Copyright © 2021 JBoss by Red Hat. All rights reserved.