<commit_before>package com.racquettrack.security.oauth;

import org.springframework.security.core.userdetails.UserDetails;

import java.util.Map;
import java.util.UUID;

/**
 * Interface that allows for retrieving a {@link UserDetails} object from the internal system and for creating
 * the representation of the user in the internal system if it doesn't exist.
 *
 * @see OAuth2UserDetailsService
 *
 * @author paul.wheeler
 */
public interface OAuth2UserDetailsLoader {

    /**
     * Retrieves the {@link UserDetails} object.
     * @param uuid The {@link UUID} of the user in the OAuth Provider's system.
     * @return The {@link UserDetails} of the user if it exists, or null if it doesn't.
     */
    public UserDetails getUserByUserId(UUID uuid);

    /**
     * Expected to be called only when the user described by {@param userInfo} has already been determined to not
     * exist in the system. Implementations should return true when it is okay for the user to be created. For example,
     * implementations may want to return false if a significant time has elapsed between the user being created in
     * the OAuth Provider and now.
     * @param userInfo A {@link Map} of the JSON user object returned by the OAuth Provider.<commit_msg>Updated interface definition to use generics to make it easier for clients<commit_after>package com.racquettrack.security.oauth;

import org.springframework.security.core.userdetails.UserDetails;

import java.util.Map;
import java.util.UUID;

/**
 * Interface that allows for retrieving a {@link UserDetails} object from the internal system and for creating
 * the representation of the user in the internal system if it doesn't exist.
 *
 * @param <T> The concrete type that implements {@link UserDetails}.
 * @see OAuth2UserDetailsService
 *
 * @author paul.wheeler
 */
public interface OAuth2UserDetailsLoader<T extends UserDetails> {

    /**
     * Retrieves the {@link UserDetails} object.
     * @param uuid The {@link UUID} of the user in the OAuth Provider's system.
     * @return The {@link UserDetails} of the user if it exists, or null if it doesn't.
     */
    public T getUserByUserId(UUID uuid);

    /**
     * Expected to be called only when the user described by {@param userInfo} has already been determined to not
     * exist in the system. Implementations should return true when it is okay for the user to be created. For example,
     * implementations may want to return false if a significant time has elapsed between the user being created in
     * the OAuth Provider and now.
     * @param userInfo A {@link Map} of the JSON user object returned by the OAuth Provider.
{'fraction_non_alphanumeric': 0.06930320150659133, 'fraction_numerical': 0.0015065913370998117, 'mean_word_length': 3.676056338028169, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3958736', 'n_tokens_mistral': 700, 'n_tokens_neox': 687, 'n_words': 335}