欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

Java 索赔类使用示例 - 例 3:verifyInjectedIssuer

最编程 2024-03-21 08:59:54
...
import org.eclipse.microprofile.jwt.Claims; //导入依赖的package包/类
@GET
@Path("/verifyInjectedIssuer")
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed("Tester")
public JsonObject verifyInjectedIssuer(@QueryParam("iss") String iss) {
    boolean pass = false;
    String msg;
    String issValue = issuer.getString();
    if(issValue == null || issValue.length() == 0) {
        msg = Claims.iss.name()+"value is null or empty, FAIL";
    }
    else if(issValue.equals(iss)) {
        msg = Claims.iss.name()+" PASS";
        pass = true;
    }
    else {
        msg = String.format("%s: %s != %s", Claims.iss.name(), issValue, iss);
    }
    JsonObject result = Json.createObjectBuilder()
        .add("pass", pass)
        .add("msg", msg)
        .build();
    return result;
}
 

推荐阅读