be.nille.jwt.components.converter.ClaimConverter Maven / Gradle / Ivy
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package be.nille.jwt.components.converter;
import be.nille.jwt.components.model.Payload;
import be.nille.jwt.components.model.Claim;
import java.util.HashMap;
import java.util.Map;
/**
* @author nholvoet
*/
public class ClaimConverter {
public Payload toPayload(final Map claimMap){
Payload payload = new Payload();
for(Map.Entry claim : claimMap.entrySet()){
Claim jwtClaim = new Claim(claim.getKey(), claim.getValue());
payload.addClaim(jwtClaim);
}
return payload;
}
public Map toClaimMap(final Payload payload){
Map claimMap = new HashMap<>();
for(Claim claim : payload.getClaims()){
claimMap.put(claim.getName(), claim.getValue());
}
return claimMap;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy