Package com.nimbusds.jwt

Examples of com.nimbusds.jwt.SignedJWT



  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


    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();
    metadata.setRedirectionURI(new URI("https://client.com/in"));
    metadata.setName("Test App");

    ClientRegistrationRequest request = new ClientRegistrationRequest(new URI("https://c2id.com/reg"), metadata, jwt, null);

    assertEquals(metadata, request.getClientMetadata());
    assertEquals(jwt, request.getSoftwareStatement());
    assertNull(request.getAccessToken());

    HTTPRequest httpRequest = request.toHTTPRequest();

    request = ClientRegistrationRequest.parse(httpRequest);

    assertEquals("https://client.com/in", request.getClientMetadata().getRedirectionURIs().iterator().next().toString());
    assertEquals("Test App", request.getClientMetadata().getName());
    assertEquals(jwt.serialize(), request.getSoftwareStatement().getParsedString());
    assertTrue(request.getSoftwareStatement().verify(new MACVerifier("abcdef1234567890")));
  }
View Full Code Here

    try {
      new ClientRegistrationRequest(
        new URI("https://c2id.com/reg"),
        metadata,
        new SignedJWT(new JWSHeader(JWSAlgorithm.HS256), claimsSet),
        null);

    } catch (IllegalArgumentException e) {

      // ok
View Full Code Here


  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

     
      return plainJWT.getJWTClaimsSet();
   
    } else if (jwt instanceof SignedJWT) {
   
      SignedJWT signedJWT = (SignedJWT)jwt;
     
      return verify(signedJWT);

    } else if (jwt instanceof EncryptedJWT) {
   
View Full Code Here

    // Get the JSON object content
    JSONObject jsonObject = httpRequest.getQueryAsJSONObject();

    // Extract the software statement if any
    SignedJWT stmt = null;

    if (jsonObject.containsKey("software_statement")) {

      try {
        stmt = SignedJWT.parse(JSONObjectUtils.getString(jsonObject, "software_statement"));
View Full Code Here

    throws Exception {

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

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

    JWSSigner signer = new MACSigner(key128);

    signedJWT.sign(signer);

    assertEquals(JWSObject.State.SIGNED, signedJWT.getState());

    Payload payload = new Payload(signedJWT);
    assertEquals(Payload.Origin.SIGNED_JWT, payload.getOrigin());
    assertEquals(signedJWT, payload.toSignedJWT());
    assertEquals(signedJWT, payload.toJWSObject());

    JWEObject jweObject = new JWEObject(new JWEHeader(JWEAlgorithm.A128KW, EncryptionMethod.A128GCM), payload);

    JWEEncrypter encrypter = new AESEncrypter(key128);

    jweObject.encrypt(encrypter);

    assertEquals(JWEObject.State.ENCRYPTED, jweObject.getState());

    String compactEncoding = jweObject.serialize();

    JWEDecrypter decrypter = new AESDecrypter(key128);

    jweObject = JWEObject.parse(compactEncoding);
    assertEquals(compactEncoding, jweObject.getParsedString());

    jweObject.decrypt(decrypter);

    payload = jweObject.getPayload();

    signedJWT = payload.toSignedJWT();

    assertEquals("alice", signedJWT.getJWTClaimsSet().getSubject());
  }
View Full Code Here

    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);
   
    return new Token(jwt.serialize());
  }
View Full Code Here

TOP

Related Classes of com.nimbusds.jwt.SignedJWT

Copyright © 2018 www.massapicom. 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.