Class AudienceClaimsValidator

    • Field Detail

      • additionalAudiencesLookupStrategy

        @Nonnull
        private BiFunction<ProfileRequestContext,​com.nimbusds.jwt.JWTClaimsSet,​Set<String>> additionalAudiencesLookupStrategy
        A strategy to lookup a list of additional audiences expected in the 'aud' claim. If they are not found, the token is rejected.
      • allowMissing

        private boolean allowMissing
        Allow a missing aud claim.
      • extraAudienceValidation

        private boolean extraAudienceValidation
        If enabled, any extra audience must be contained in the List returned from the additionalAudiencesLookupStrategy. Defaults to false.
    • Constructor Detail

      • AudienceClaimsValidator

        public AudienceClaimsValidator()
        Constructor.
    • Method Detail

      • setAudienceLookupStrategy

        public void setAudienceLookupStrategy​(@Nonnull
                                              BiFunction<ProfileRequestContext,​com.nimbusds.jwt.JWTClaimsSet,​String> strategy)
        Set the audience lookup strategy.
        Parameters:
        strategy - the strategy.
      • setAdditionalAudiencesLookupStrategy

        public void setAdditionalAudiencesLookupStrategy​(@Nonnull
                                                         BiFunction<ProfileRequestContext,​com.nimbusds.jwt.JWTClaimsSet,​Set<String>> strategy)
        Set the strategy used to lookup the list of additional audiences to find in the 'aud' claim.
        Parameters:
        strategy - the strategy
        Since:
        2.2.0
      • setAllowMissing

        public void setAllowMissing​(boolean flag)
        Set whether a missing 'aud' claim is valid or not.

        Defaults to false.

        Parameters:
        flag - flag to set
        Since:
        2.1.0
      • setExtraAudienceValidation

        public void setExtraAudienceValidation​(boolean flag)
        Set whether to enable extra audience validation.

        Defaults to false.

        Parameters:
        flag - the flag to set
        Since:
        2.2.0
      • resolveAcceptedAudiences

        @Nonnull
        @NotEmpty
        protected Set<String> resolveAcceptedAudiences​(@Nonnull
                                                       com.nimbusds.jwt.JWTClaimsSet claims,
                                                       @Nonnull
                                                       ProfileRequestContext context)
                                                throws JWTValidationException
        Resolve the set of accepted audiences. This method is mostly a hook for classes extending this validator: in this case it simply returns the resolved single accepted audience in the set.
        Parameters:
        claims - the claims fed for the audience lookup strategy
        context - the profile request context fed for the audience lookup strategy
        Returns:
        the set containing the accepted audience claim
        Throws:
        JWTValidationException - if the audience value could not be resolved via lookup strategy