Class ScopeUtil


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

      Fields 
      Modifier and Type Field Description
      private static org.slf4j.Logger log
      Class logger.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ScopeUtil()
      Private constructor.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static net.shibboleth.idp.attribute.IdPAttribute buildAttribute​(String attributeId, com.nimbusds.oauth2.sdk.Scope scope)
      Builds an IdPAttribute with given identifier and contents taken from the given scope.
      static com.nimbusds.oauth2.sdk.Scope buildIntersectedScope​(net.shibboleth.idp.attribute.IdPAttribute attribute, com.nimbusds.oauth2.sdk.Scope scope)
      Builds intersected Scope from the given IdPAttribute and Scope.
      static com.nimbusds.oauth2.sdk.Scope buildIntersectedScope​(net.shibboleth.idp.attribute.resolver.scripted.ScriptedIdPAttribute attribute, com.nimbusds.oauth2.sdk.Scope scope)
      Builds intersected Scope from the given ScriptedIdPAttribute and Scope.
      static com.nimbusds.oauth2.sdk.Scope buildScope​(net.shibboleth.idp.attribute.IdPAttribute attribute)
      Builds Scope from the given attribute contents.
      static com.nimbusds.oauth2.sdk.Scope buildScope​(net.shibboleth.idp.attribute.resolver.scripted.ScriptedIdPAttribute attribute)
      Builds Scope from the given ScriptedIdPAttribute.
      static void populateScriptedAttribute​(net.shibboleth.idp.attribute.resolver.scripted.ScriptedIdPAttribute attribute, com.nimbusds.oauth2.sdk.Scope scope)
      Adds values from the given scope to the ScriptedIdPAttribute.
      static void populateScriptedAttribute​(net.shibboleth.idp.attribute.resolver.scripted.ScriptedIdPAttribute attribute, net.shibboleth.idp.attribute.resolver.scripted.ScriptedIdPAttribute source)
      Adds values from the given ScriptedIdPAttribute to another ScriptedIdPAttribute.
      static void removeValue​(com.nimbusds.oauth2.sdk.Scope scope, String value)
      Removes a single value from the given Scope.
      static void setAttributeValues​(net.shibboleth.idp.attribute.IdPAttribute attribute, com.nimbusds.oauth2.sdk.Scope scope)
      Sets the contents for IdPAttribute from the given scope.
    • Field Detail

      • log

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

      • ScopeUtil

        private ScopeUtil()
        Private constructor.
    • Method Detail

      • buildAttribute

        @Nonnull
        public static net.shibboleth.idp.attribute.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
                                              net.shibboleth.idp.attribute.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
                                                     net.shibboleth.idp.attribute.resolver.scripted.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
      • populateScriptedAttribute

        public static void populateScriptedAttribute​(@Nonnull
                                                     net.shibboleth.idp.attribute.resolver.scripted.ScriptedIdPAttribute attribute,
                                                     @Nullable
                                                     net.shibboleth.idp.attribute.resolver.scripted.ScriptedIdPAttribute source)
                                              throws net.shibboleth.idp.attribute.resolver.ResolutionException
        Adds values from the given ScriptedIdPAttribute to another ScriptedIdPAttribute.
        Parameters:
        attribute - The attribute whose contents are fulfilled
        source - The contents to fulfill for the attribute
        Throws:
        net.shibboleth.idp.attribute.resolver.ResolutionException - If the soure attribute contents cannot be accessed
      • buildScope

        @Nonnull
        public static com.nimbusds.oauth2.sdk.Scope buildScope​(@Nullable
                                                               net.shibboleth.idp.attribute.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
      • buildScope

        @Nonnull
        public static com.nimbusds.oauth2.sdk.Scope buildScope​(@Nullable
                                                               net.shibboleth.idp.attribute.resolver.scripted.ScriptedIdPAttribute attribute)
                                                        throws net.shibboleth.idp.attribute.resolver.ResolutionException
        Builds Scope from the given ScriptedIdPAttribute. The contents are assumed to be String.
        Parameters:
        attribute - The attribute whose contents are used for the scope
        Returns:
        The built scope
        Throws:
        net.shibboleth.idp.attribute.resolver.ResolutionException - If the attribute values cannot be accessed
      • buildIntersectedScope

        @Nonnull
        public static com.nimbusds.oauth2.sdk.Scope buildIntersectedScope​(@Nullable
                                                                          net.shibboleth.idp.attribute.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
                                                                          net.shibboleth.idp.attribute.resolver.scripted.ScriptedIdPAttribute attribute,
                                                                          @Nullable
                                                                          com.nimbusds.oauth2.sdk.Scope scope)
                                                                   throws net.shibboleth.idp.attribute.resolver.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:
        net.shibboleth.idp.attribute.resolver.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