// Path: idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/config/OIDCConstants.java
// public interface OIDCConstants {
// 
//     /**
//      * The constant ACR_VALUES.
//      */
//     String ACR_VALUES = "acr_values";
//     
//     /**
//      * The constant ID_TOKEN.
//      */
//     String ID_TOKEN = "idtoken";
//     
//     /**
//      * The constant AUTH_TIME.
//      */
//     String AUTH_TIME = "auth_time";
// 
//     /**
//      * The constant ACR.
//      */
//     String ACR = "acr";
// 
//     /**
//      * The constant AMR.
//      */
//     String AMR = "amr";
// 
//     /**
//      * The constant TOKEN.
//      */
//     String TOKEN = "token";
// 
//     /**
//      * The constant AT_HASH.
//      */
//     String AT_HASH = "at_hash";
// 
//     /**
//      * The constant KID.
//      */
//     String KID = "kid";
// 
//     /**
//      * The constant ROLE_USER.
//      */
//     String ROLE_USER = "ROLE_USER";
// 
//     /**
//      * The constant ROLE_CLIENT.
//      */
//     String ROLE_CLIENT = "ROLE_CLIENT";
// }


import com.google.common.base.Strings;
import net.shibboleth.idp.authn.AuthenticationFlowDescriptor;
import net.shibboleth.idp.authn.context.AuthenticationContext;
import net.shibboleth.idp.authn.context.RequestedPrincipalContext;
import net.shibboleth.idp.oidc.config.OIDCConstants;
import net.shibboleth.idp.profile.AbstractProfileAction;
import net.shibboleth.idp.saml.authn.principal.AuthnContextClassRefPrincipal;
import org.mitre.oauth2.service.ClientDetailsEntityService;
import org.opensaml.profile.context.ProfileRequestContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.provider.AuthorizationRequest;
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.RequestContext;
import javax.annotation.Nonnull;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
    private void addRequestedPrincipalIntoContext(final AuthenticationContext ac, final List<Principal> principals) {
        final RequestedPrincipalContext rpc = new RequestedPrincipalContext();
        rpc.setOperator("exact");
        rpc.setRequestedPrincipals(principals);
        ac.addSubcontext(rpc, true);
    }

    /**
     * Process acr values based on principal weight map.
     *
     * @param principals the principals
     */
    private void processAcrValuesBasedOnPrincipalWeightMap(final List<Principal> principals) {
        if (principals.isEmpty()) {
            final AuthnContextClassRefPrincipal[] principalArray =
                    this.authenticationPrincipalWeightMap.keySet()
                            .toArray(new AuthnContextClassRefPrincipal[]{});
            Arrays.sort(principalArray, new WeightedComparator());
            principals.add(principalArray[principalArray.length - 1]);
        }
    }

    /**
     * Process requested acr values if any.
     *
     * @param authorizationRequest the authorization request
     * @param principals           the principals
     */
    private void processRequestedAcrValuesIfAny(final AuthorizationRequest authorizationRequest, 
                                                final List<Principal> principals) {
// Path: idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/config/OIDCConstants.java
// public interface OIDCConstants {
// 
//     /**
//      * The constant ACR_VALUES.
//      */
//     String ACR_VALUES = "acr_values";
//     
//     /**
//      * The constant ID_TOKEN.
//      */
//     String ID_TOKEN = "idtoken";
//     
//     /**
//      * The constant AUTH_TIME.
//      */
//     String AUTH_TIME = "auth_time";
// 
//     /**
//      * The constant ACR.
//      */
//     String ACR = "acr";
// 
//     /**
//      * The constant AMR.
//      */
//     String AMR = "amr";
// 
//     /**
//      * The constant TOKEN.
//      */
//     String TOKEN = "token";
// 
//     /**
//      * The constant AT_HASH.
//      */
//     String AT_HASH = "at_hash";
// 
//     /**
//      * The constant KID.
//      */
//     String KID = "kid";
// 
//     /**
//      * The constant ROLE_USER.
//      */
//     String ROLE_USER = "ROLE_USER";
// 
//     /**
//      * The constant ROLE_CLIENT.
//      */
//     String ROLE_CLIENT = "ROLE_CLIENT";
// }


// Path: idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/flow/BuildAuthenticationContextAction.java
import com.google.common.base.Strings;
import net.shibboleth.idp.authn.AuthenticationFlowDescriptor;
import net.shibboleth.idp.authn.context.AuthenticationContext;
import net.shibboleth.idp.authn.context.RequestedPrincipalContext;
import net.shibboleth.idp.oidc.config.OIDCConstants;
import net.shibboleth.idp.profile.AbstractProfileAction;
import net.shibboleth.idp.saml.authn.principal.AuthnContextClassRefPrincipal;
import org.mitre.oauth2.service.ClientDetailsEntityService;
import org.opensaml.profile.context.ProfileRequestContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.provider.AuthorizationRequest;
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.RequestContext;
import javax.annotation.Nonnull;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Map;

    private void addRequestedPrincipalIntoContext(final AuthenticationContext ac, final List<Principal> principals) {
        final RequestedPrincipalContext rpc = new RequestedPrincipalContext();
        rpc.setOperator("exact");
        rpc.setRequestedPrincipals(principals);
        ac.addSubcontext(rpc, true);
    }

    /**
     * Process acr values based on principal weight map.
     *
     * @param principals the principals
     */
    private void processAcrValuesBasedOnPrincipalWeightMap(final List<Principal> principals) {
        if (principals.isEmpty()) {
            final AuthnContextClassRefPrincipal[] principalArray =
                    this.authenticationPrincipalWeightMap.keySet()
                            .toArray(new AuthnContextClassRefPrincipal[]{});
            Arrays.sort(principalArray, new WeightedComparator());
            principals.add(principalArray[principalArray.length - 1]);
        }
    }

    /**
     * Process requested acr values if any.
     *
     * @param authorizationRequest the authorization request
     * @param principals           the principals
     */
    private void processRequestedAcrValuesIfAny(final AuthorizationRequest authorizationRequest, 
                                                final List<Principal> principals) {
        if (authorizationRequest.getExtensions().containsKey(OIDCConstants.ACR_VALUES)) {