26 lines
961 B
Java

package fr.titionfire.ffsaf.utils;
import org.eclipse.microprofile.jwt.JsonWebToken;
public class GroupeUtils {
public static boolean isInClubGroup(long id, JsonWebToken accessToken) {
if (accessToken.getClaim("user_groups") instanceof Iterable<?>) {
for (Object str : (Iterable<?>) accessToken.getClaim("user_groups")) {
if (str.toString().substring(1, str.toString().length() - 1).startsWith("/club/" + id + "-"))
return true;
}
}
return false;
}
public static boolean contains(String string, JsonWebToken accessToken) {
if (accessToken.getClaim("user_groups") instanceof Iterable<?>) {
for (Object str : (Iterable<?>) accessToken.getClaim("user_groups")) {
if (str.toString().substring(1, str.toString().length() - 1).contains(string))
return true;
}
}
return false;
}
}