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 java.util.Optional;

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

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

class InnerClaimsWrapper {

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

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

        Optional innerClaim = Optional.empty();

        for (JWTClaim jwtClaim : reverse) {
            innerClaim = Optional.of(JWTClaim.builder().from(jwtClaim).innerClaim(innerClaim).build());
        }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy