Package com.nimbusds.jwt

Examples of com.nimbusds.jwt.SignedJWT


      "eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt" +
      "cGxlLmNvbS9pc19yb290Ijp0cnVlfQ" +
      "." +
      "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk";

    SignedJWT signedJWT = SignedJWT.parse(s);

    Payload payload = new Payload(signedJWT);

    assertEquals(Payload.Origin.SIGNED_JWT, payload.getOrigin());
    assertEquals(signedJWT, payload.toSignedJWT());
View Full Code Here



  public void testRejectUnsignedJWT() {

    try {
      new Payload(new SignedJWT(new JWSHeader(JWSAlgorithm.HS256), new JWTClaimsSet()));
      fail();
    } catch (IllegalArgumentException e) {
      assertEquals("The JWT must be signed", e.getMessage());
    }
  }
View Full Code Here

  public static PrivateKeyJWT parse(final Map<String,String> params)
    throws ParseException {
 
    JWTAuthentication.ensureClientAssertionType(params);
   
    SignedJWT clientAssertion = JWTAuthentication.parseClientAssertion(params);

    PrivateKeyJWT privateKeyJWT;

    try {
      privateKeyJWT = new PrivateKeyJWT(clientAssertion);
View Full Code Here

  public static ClientSecretJWT parse(final Map<String,String> params)
    throws ParseException {
 
    JWTAuthentication.ensureClientAssertionType(params);
   
    SignedJWT clientAssertion = JWTAuthentication.parseClientAssertion(params);

    ClientSecretJWT clientSecretJWT;

    try {
      clientSecretJWT = new ClientSecretJWT(clientAssertion);
View Full Code Here

    JWTClaimsSet claimsSet = claims.toJWTClaimsSet();

    Secret secret = new Secret();

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

    jwt.sign(new MACSigner(secret.getValueBytes()));

    UserInfoSuccessResponse response = new UserInfoSuccessResponse(jwt);

    assertEquals(jwt, response.getUserInfoJWT());
    assertEquals("application/jwt; charset=UTF-8", response.getContentType().toString());
    assertNull(response.getUserInfo());

    HTTPResponse httpResponse = response.toHTTPResponse();

    response = UserInfoSuccessResponse.parse(httpResponse);

    assertEquals("application/jwt; charset=UTF-8", response.getContentType().toString());
    assertNull(response.getUserInfo());

    jwt = (SignedJWT)response.getUserInfoJWT();

    assertTrue(jwt.getState().equals(JWSObject.State.SIGNED));

    claims = new UserInfo(response.getUserInfoJWT().getJWTClaimsSet().toJSONObject());

    assertEquals("alice", claims.getSubject().getValue());
    assertEquals("Alice Adams", claims.getName());
View Full Code Here

    claimsSet.setSubject("alice");
    claimsSet.setIssueTime(new Date(10000l));
    claimsSet.setExpirationTime(new Date(20000l));
    claimsSet.setClaim("nonce", "123");

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

    idToken.sign(new MACSigner("1234567890abcdef"));

    AuthenticationSuccessResponse response = new AuthenticationSuccessResponse(
      REDIRECT_URI, null, idToken, null, new State("abc"));

    assertEquals(REDIRECT_URI, response.getRedirectionURI());
View Full Code Here

    claimsSet.setSubject("alice");
    claimsSet.setIssueTime(new Date(10000l));
    claimsSet.setExpirationTime(new Date(20000l));
    claimsSet.setClaim("nonce", "123");

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

    idToken.sign(new MACSigner("1234567890abcdef"));

    AuthenticationSuccessResponse response = new AuthenticationSuccessResponse(
      REDIRECT_URI, code, idToken, null, new State("abc"));

    assertEquals(REDIRECT_URI, response.getRedirectionURI());
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.setIssuer("https://c2id.com");

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

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

    OIDCClientRegistrationRequest request = new OIDCClientRegistrationRequest(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 = OIDCClientRegistrationRequest.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 OIDCClientRegistrationRequest(
        new URI("https://c2id.com/reg"),
        metadata,
        new SignedJWT(new JWSHeader(JWSAlgorithm.HS256), claimsSet),
        null);

    } catch (IllegalArgumentException e) {

      // ok
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.