All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mercateo.spring.security.jwt.token.extractor.InnerClaimsWrapper Maven / Gradle / Ivy

There is a newer version: 2.1.1
Show newest version
package com.mercateo.spring.security.jwt.token.extractor;

import com.mercateo.spring.security.jwt.token.claim.JWTClaim;

import io.vavr.collection.List;
import io.vavr.collection.Map;
import io.vavr.control.Option;

class InnerClaimsWrapper {

    Map wrapInnerClaims(List claims) {
        return claims.groupBy(JWTClaim::name).mapValues(this::wrapGroupedClaims);
    }

    private JWTClaim wrapGroupedClaims(List claims) {
        final List reverse = claims.reverse();

        Option innerClaim = Option.none();

        for (JWTClaim jwtClaim : reverse) {
            innerClaim = Option.some(JWTClaim.builder().from(jwtClaim).withInnerClaim(innerClaim).build());
        }

        // noinspection ConstantConditions
        return innerClaim.get();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy