Package org.eclipse.orion.server.authentication.oauth

Examples of org.eclipse.orion.server.authentication.oauth.OAuthException


    if(type.equals("google")){
      oauthParams = new GoogleOAuthParams(req, login);
    }else if(type.equals("github")){
      oauthParams = new GitHubOAuthParams(req, login);
    }else{
      throw new OAuthException("No OAuth provider given");
    }
    return getOAuthParams();
  }
View Full Code Here


    return getOAuthParams();
  }

  private OAuthParams getOAuthParams() throws OAuthException{
    if (oauthParams == null)
      throw new OAuthException("No OAuth provider given");
    return oauthParams;
  }
View Full Code Here

    try {
      JSONObject json = new JSONObject(oauthAccessTokenResponse.getBody());
      String jwt = json.getString(TOKEN_PARAMETER);
      parseToken(jwt);
    } catch (JSONException e) {
      throw new OAuthException(e);
    }
  }
View Full Code Here

  }

  private void parseToken(String jwt) throws OAuthException {
    String [] sections = jwt.split("\\.");
    if(sections.length != 3)
      throw new OAuthException("An error occured while authenticating");
    // No validation required since the token comes directly from the google server
    // JWT Structure
    // Header.Claim.Signature
    String claim = sections[1];
    int buffer = 4 - (claim.length() % 4);
    // Encoded base64 should never need 3 buffer characters
    if(buffer == 3)
      throw new OAuthException("An error occured while authenticating");
    // Don't add 4 buffer characters
    for(int i = 0; i < buffer && buffer != 4; i++) {
      claim += "=";
    }
    String decodedClaim = new String(Base64.decode(claim.getBytes()));
    JSONObject jsonClaim;
    try {
      jsonClaim = new JSONObject(decodedClaim);
      userId = jsonClaim.getString(ID_PARAMETER);
      provider = jsonClaim.getString(PROVIDER_PARAMETER);
      openid_id = jsonClaim.getString(OPEN_ID_PARAMETER);
    } catch (JSONException e) {
      throw new OAuthException(e);
    }
    email = "";
    email_verified = false;
    try{
      email = jsonClaim.getString(EMAIL_PARAMETER);
View Full Code Here

      URL currentURL = getCurrentURL();
      // Add realm for openId 2.0 migration
      String realm = new URL(currentURL.getProtocol(), currentURL.getHost(), currentURL.getPort(), "").toString();
      requestBuiler.setParameter(OPEN_ID_PARAMETER, realm);
    } catch (MalformedURLException e) {
      throw new OAuthException("An Error occured while building the request URL");
    }
  }
View Full Code Here

      json = new JSONObject(body);
      username = json.getString(USERNAME_PARAMETER);
      id = json.getString(ID_PARAMETER);
      url = json.getString(URL_PARAMETER);
    } catch (JSONException e) {
      throw new OAuthException("An error occured while authenticating the user");
    }
  }
View Full Code Here

          email = emailObject.getString(EMAIL_PARAMETER);
          break;
        }
      }
    } catch (JSONException e) {
      throw new OAuthException("An error occured while authenticating the user");
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.orion.server.authentication.oauth.OAuthException

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.