Examples of JWTClaimsSet


Examples of com.nimbusds.jwt.JWTClaimsSet


  public void testRejectUnsignedSoftwareStatement()
    throws Exception {

    JWTClaimsSet claimsSet = new JWTClaimsSet();
    claimsSet.setIssuer("https://c2id.com");

    OIDCClientMetadata metadata = new OIDCClientMetadata();
    metadata.setRedirectionURI(new URI("https://client.com/in"));
    metadata.setName("Test App");
View Full Code Here

Examples of com.nimbusds.jwt.JWTClaimsSet


  public void testRejectSoftwareStatementWithoutIssuer()
    throws Exception {

    SignedJWT jwt = new SignedJWT(new JWSHeader(JWSAlgorithm.HS256), new JWTClaimsSet());
    jwt.sign(new MACSigner("abcdef1234567890"));

    OIDCClientMetadata metadata = new OIDCClientMetadata();
    metadata.setRedirectionURI(new URI("https://client.com/in"));
    metadata.setName("Test App");
View Full Code Here

Examples of com.nimbusds.jwt.JWTClaimsSet


  public void testParseJWTBearer()
    throws Exception {

    JWTClaimsSet claimsSet = new JWTClaimsSet();
    claimsSet.setSubject("alice");

    JWT assertion = new PlainJWT(claimsSet);

    Map<String,String> params = new HashMap<>();
    params.put("grant_type", GrantType.JWT_BEARER.getValue());
View Full Code Here

Examples of com.nimbusds.jwt.JWTClaimsSet


  public void testSoftwareStatement()
    throws Exception {

    JWTClaimsSet claimsSet = new JWTClaimsSet();
    claimsSet.setIssuer("https://c2id.com");

    SignedJWT jwt = new SignedJWT(new JWSHeader(JWSAlgorithm.HS256), claimsSet);
    jwt.sign(new MACSigner("abcdef1234567890"));

    ClientMetadata metadata = new ClientMetadata();
View Full Code Here

Examples of com.nimbusds.jwt.JWTClaimsSet


  public void testRejectUnsignedSoftwareStatement()
    throws Exception {

    JWTClaimsSet claimsSet = new JWTClaimsSet();
    claimsSet.setIssuer("https://c2id.com");

    ClientMetadata metadata = new ClientMetadata();
    metadata.setRedirectionURI(new URI("https://client.com/in"));
    metadata.setName("Test App");
View Full Code Here

Examples of com.nimbusds.jwt.JWTClaimsSet


  public void testRejectSoftwareStatementWithoutIssuer()
    throws Exception {

    SignedJWT jwt = new SignedJWT(new JWSHeader(JWSAlgorithm.HS256), new JWTClaimsSet());
    jwt.sign(new MACSigner("abcdef1234567890"));

    ClientMetadata metadata = new ClientMetadata();
    metadata.setRedirectionURI(new URI("https://client.com/in"));
    metadata.setName("Test App");
View Full Code Here

Examples of com.nimbusds.jwt.JWTClaimsSet


  public void testWithNestedSignedJWT()
    throws Exception {

    JWTClaimsSet claimsSet = new JWTClaimsSet();
    claimsSet.setSubject("alice");

    SignedJWT signedJWT = new SignedJWT(new JWSHeader(JWSAlgorithm.HS256), claimsSet);

    JWSSigner signer = new MACSigner(key128);
View Full Code Here

Examples of com.nimbusds.jwt.JWTClaimsSet

    String authHeader = httpRequest.getHeader(AuthUtils.AUTH_HEADER_KEY);
   
    if (StringUtils.isBlank(authHeader) || authHeader.split(" ").length != 2) {
      httpResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, AUTH_ERROR_MSG);
    } else {
      JWTClaimsSet claimSet = null;
      try {
        claimSet = (JWTClaimsSet) AuthUtils.decodeToken(authHeader);
      } catch (ParseException e) {
        httpResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, JWT_ERROR_MSG);
      }
      // ensure that the token is not expired
      if (new DateTime(claimSet.getExpirationTime()).isBefore(DateTime.now())) {
        httpResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, EXPIRE_ERROR_MSG);
      } else {
        chain.doFilter(request, response);
      }
    } 
View Full Code Here

Examples of com.nimbusds.jwt.JWTClaimsSet

  public static ReadOnlyJWTClaimsSet decodeToken(String authHeader) throws ParseException {
    return SignedJWT.parse(getSerializedToken(authHeader)).getJWTClaimsSet();
  }
 
  public static Token createToken(String host, long sub) throws JOSEException {
    JWTClaimsSet claim = new JWTClaimsSet();
    claim.setSubject(Long.toString(sub));
    claim.setIssuer(host);
    claim.setIssueTime(DateTime.now().toDate());
    claim.setExpirationTime(DateTime.now().plusDays(14).toDate());
   
    JWSSigner signer = new MACSigner(TOKEN_SECRET);
    SignedJWT jwt = new SignedJWT(JWT_HEADER, claim);
    jwt.sign(signer);
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.