Class ScopeUtil


  • public final class ScopeUtil
    extends Object
    Static helper methods for handling Scope objects, especially with IdP attributes.
    Since:
    3.2.0
    • Field Detail

      • log

        private static org.slf4j.Logger log
        Class logger.
    • Constructor Detail

      • ScopeUtil

        private ScopeUtil()
        Private constructor.
    • Method Detail

      • buildAttribute

        @Nonnull
        public static IdPAttribute buildAttribute​(@Nonnull
                                                  String attributeId,
                                                  @Nullable
                                                  com.nimbusds.oauth2.sdk.Scope scope)
        Builds an IdPAttribute with given identifier and contents taken from the given scope.
        Parameters:
        attributeId - The attribute ID to use
        scope - The contents for the attribute
        Returns:
        The built attribute
      • setAttributeValues

        public static void setAttributeValues​(@Nonnull
                                              IdPAttribute attribute,
                                              @Nullable
                                              com.nimbusds.oauth2.sdk.Scope scope)
        Sets the contents for IdPAttribute from the given scope.
        Parameters:
        attribute - The attribute whose contents are set
        scope - The contents for the attribute
      • populateScriptedAttribute

        public static void populateScriptedAttribute​(@Nonnull
                                                     ScriptedIdPAttribute attribute,
                                                     @Nullable
                                                     com.nimbusds.oauth2.sdk.Scope scope)
        Adds values from the given scope to the ScriptedIdPAttribute.
        Parameters:
        attribute - The attribute whose contents are fulfilled
        scope - The contents to fulfill for the attribute
      • buildScope

        @Nonnull
        public static com.nimbusds.oauth2.sdk.Scope buildScope​(@Nullable
                                                               IdPAttribute attribute)
        Builds Scope from the given attribute contents. Only the StringAttributeValues are recognized.
        Parameters:
        attribute - The attribute whose contents are used for the scope
        Returns:
        The built scope
      • buildIntersectedScope

        @Nonnull
        public static com.nimbusds.oauth2.sdk.Scope buildIntersectedScope​(@Nullable
                                                                          IdPAttribute attribute,
                                                                          @Nullable
                                                                          com.nimbusds.oauth2.sdk.Scope scope)
        Builds intersected Scope from the given IdPAttribute and Scope.
        Parameters:
        attribute - The attribute whose contents are processed
        scope - The existing scope whose contents are processed
        Returns:
        The intersection of the two contents
      • buildIntersectedScope

        @Nonnull
        public static com.nimbusds.oauth2.sdk.Scope buildIntersectedScope​(@Nullable
                                                                          ScriptedIdPAttribute attribute,
                                                                          @Nullable
                                                                          com.nimbusds.oauth2.sdk.Scope scope)
                                                                   throws ResolutionException
        Builds intersected Scope from the given ScriptedIdPAttribute and Scope.
        Parameters:
        attribute - The attribute whose contents are processed
        scope - The existing scope whose contents are processed
        Returns:
        The intersection of the two contents
        Throws:
        ResolutionException - If th attribute values cannot be accessed
      • removeValue

        public static void removeValue​(@Nonnull
                                       com.nimbusds.oauth2.sdk.Scope scope,
                                       @Nonnull
                                       String value)
        Removes a single value from the given Scope.
        Parameters:
        scope - The scope to modify
        value - The value to be removed if it exists