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

de.adorsys.sts.tokenauth.StringListRolesParser Maven / Gradle / Ivy

There is a newer version: 1.2.2
Show newest version
package de.adorsys.sts.tokenauth;

import com.nimbusds.jwt.JWTClaimsSet;

import java.text.ParseException;
import java.util.List;

public class StringListRolesParser {

	public void extractRoles(JWTClaimsSet claimSet, String claimName, final List results) {
		List scpClaims = readClaim(claimSet, claimName);
		if(scpClaims!=null && !scpClaims.isEmpty()){
			for (String scp : scpClaims) {
				if(scp!=null && !results.contains(scp)){
					results.add(scp);
				}
			}
		}
	}
	
	private List readClaim(JWTClaimsSet claimSet, String claimName){
		try {
			return claimSet.getStringListClaim(claimName);
		} catch (ParseException e) {
			// TODO log exception.
			return null;
		}
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy