@Override
  public String generateValue(WebContext webContext) {
    Optional<String> portNumber = webContext
        .getRequestHeader(HiveSamlUtils.SSO_TOKEN_RESPONSE_PORT);
    if (!portNumber.isPresent()) {
      throw new RuntimeException(
          "SAML response port header " + HiveSamlUtils.SSO_TOKEN_RESPONSE_PORT
              + " is not set ");
    }
    int port = Integer.parseInt(portNumber.get());
    String relayState = UUID.randomUUID().toString();
    // note that clientIdentifier below is a different UUID than relayState.
    // relayState should not contain any secrets since it is visible on the URL string.
    HiveSamlRelayStateInfo relayStateInfo = new HiveSamlRelayStateInfo(port,
        UUID.randomUUID().toString());
    webContext.setResponseHeader(HiveSamlUtils.SSO_CLIENT_IDENTIFIER,
        relayStateInfo.getClientIdentifier());
    relayStateCache.put(relayState, relayStateInfo);
    return relayState;
  }
This method is used to generate the RelayState for a given SAML authentication
request. It generates a UUID which is added to the SAMl authentication request URL
as a query parameter RelayState. This RelayState is resent by the IDP later as per
SAML specification and it is used to extract the state associated with the given
SAML authentication request. It is important to note that the RelayState identifier
itself should not contain any secrets since it can be seen by anyone from the URL.
@return RelayState identifier to be used as value of the query parameter RelayState
in the SAML authentication request redirect URL.
service/src/java/org/apache/hive/service/auth/saml/HiveSamlRelayStateStore.java