Examples of JWT


Examples of com.nimbusds.jwt.JWT

    String assertionString = params.get("assertion");

    if (assertionString == null || assertionString.trim().isEmpty())
      throw new ParseException("Missing or empty \"assertion\" parameter", OAuth2Error.INVALID_REQUEST);

    JWT assertion;

    try {
      assertion = JWTParser.parse(assertionString);
    } catch (java.text.ParseException e) {
      throw new ParseException("The \"assertion\" is not a JWT: " + e.getMessage(), OAuth2Error.INVALID_REQUEST, e);
View Full Code Here

Examples of com.nimbusds.jwt.JWT

    throws Exception {

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

    JWT assertion = new PlainJWT(claimsSet);

    JWTBearerGrant grant = new JWTBearerGrant(assertion);

    assertEquals(GrantType.JWT_BEARER, grant.getType());
    assertEquals(assertion, grant.getJWTAssertion());
    assertEquals(assertion.serialize(), grant.getAssertion());

    Map<String,String> params = grant.toParameters();
    assertEquals(GrantType.JWT_BEARER.getValue(), params.get("grant_type"));
    assertEquals(assertion.serialize(), params.get("assertion"));
    assertEquals(2, params.size());

    grant = JWTBearerGrant.parse(params);
    assertEquals(GrantType.JWT_BEARER, grant.getType());
    assertEquals(assertion.serialize(), grant.getAssertion());
  }
View Full Code Here

Examples of com.nimbusds.jwt.JWT

    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());
    params.put("assertion", assertion.serialize());

    JWTBearerGrant grant = (JWTBearerGrant)AuthorizationGrant.parse(params);

    assertEquals(GrantType.JWT_BEARER, grant.getType());
    assertEquals(assertion.serialize(), grant.getAssertion());
  }
View Full Code Here

Examples of com.nimbusds.jwt.JWT

      "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk";

    response.setContentType(CommonContentTypes.APPLICATION_JWT);
    response.setContent(exampleJWTString);

    JWT jwt = response.getContentAsJWT();
    assertEquals(JWSAlgorithm.HS256, jwt.getHeader().getAlgorithm());
  }
View Full Code Here

Examples of com.nimbusds.jwt.JWT

     
      response = new UserInfoSuccessResponse(claimsSet);
    }
    else if (ct.match(CommonContentTypes.APPLICATION_JWT)) {
   
      JWT jwt;
     
      try {
        jwt = httpResponse.getContentAsJWT();
       
      } catch (ParseException e) {
View Full Code Here

Examples of com.nimbusds.jwt.JWT

  public static OIDCAccessTokenResponse parse(final JSONObject jsonObject)
    throws ParseException {
   
    AccessTokenResponse atr = AccessTokenResponse.parse(jsonObject);
   
    JWT idToken = null;
   
    if (jsonObject.containsKey("id_token")) {
     
      try {
        idToken = JWTParser.parse(JSONObjectUtils.getString(jsonObject, "id_token"));
View Full Code Here

Examples of com.nimbusds.jwt.JWT

    throws ParseException {

    AuthorizationSuccessResponse asr = AuthorizationSuccessResponse.parse(redirectURI, params);

    // Parse id_token parameter
    JWT idToken = null;
   
    if (params.get("id_token") != null) {
     
      try {
        idToken = JWTParser.parse(params.get("id_token"));
View Full Code Here

Examples of com.nimbusds.jwt.JWT

    }


    v = params.get("id_token_hint");
   
    JWT idTokenHint = null;
   
    if (StringUtils.isNotBlank(v)) {
   
      try {
        idTokenHint = JWTParser.parse(v);
       
      } catch (java.text.ParseException e) {
   
        throw new ParseException("Invalid \"id_token_hint\" parameter: " + e.getMessage(),
                           OAuth2Error.INVALID_REQUEST,
                           clientID, redirectURI, state, e);
      }
    }

    String loginHint = params.get("login_hint");


    v = params.get("acr_values");

    List<ACR> acrValues = null;

    if (StringUtils.isNotBlank(v)) {

      acrValues = new LinkedList<>();

      StringTokenizer st = new StringTokenizer(v, " ");

      while (st.hasMoreTokens()) {

        acrValues.add(new ACR(st.nextToken()));
      }
    }


    v = params.get("claims");

    ClaimsRequest claims = null;

    if (StringUtils.isNotBlank(v)) {

      JSONObject jsonObject;

      try {
        jsonObject = JSONObjectUtils.parseJSONObject(v);

      } catch (ParseException e) {

        throw new ParseException("Invalid \"claims\" parameter: " + e.getMessage(),
                           OAuth2Error.INVALID_REQUEST,
                           clientID, redirectURI, state, e);
      }

      // Parse exceptions silently ignored
      claims = ClaimsRequest.parse(jsonObject);
    }
   
   
    v = params.get("request_uri");
   
    URI requestURI = null;
   
    if (StringUtils.isNotBlank(v)) {

      try {
        requestURI = new URI(v);
   
      } catch (URISyntaxException e) {
     
        throw new ParseException("Invalid \"request_uri\" parameter: " + e.getMessage(),
                           OAuth2Error.INVALID_REQUEST,
                           clientID, redirectURI, state, e);
      }
    }

    v = params.get("request");

    JWT requestObject = null;

    if (StringUtils.isNotBlank(v)) {

      // request_object and request_uri must not be defined at the same time
      if (requestURI != null) {
View Full Code Here

Examples of com.nimbusds.jwt.JWT

      // Return the same request
      return request;
    }

    try {
      JWT jwt;

      if (request.getRequestURI() != null) {

        // Download request object
        URL requestURL;
View Full Code Here

Examples of org.apache.oltu.oauth2.jwt.JWT

public final class JWTWriterTestCase implements IOTestCaseConstants {

    @Test
    public void write() {
        JWT jwt = new JWT.Builder()
                          // header
                          .setHeaderAlgorithm("RS256")
                          .setHeaderCustomField("kid", "be1da0b3567bd265a25098fbcc2b09f21345b3a2")
                          // claimset
                          .setClaimsSetAudience("788732372078.apps.googleusercontent.com")
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.