Examples of JiveInstance


Examples of com.ndriven.jive.cloud.examples.addon.model.JiveInstance

    this.jiveInstanceHolder = jiveInstanceHolder;
  }

  @Override
  public String getAccessToken() throws JiveInstanceNotFoundException, OAuthCodeNotFoundException {
    JiveInstance jiveInstance = null;
    try {
      jiveInstance = jiveInstanceHolder.getJiveInstance();
      if (jiveInstance == null) throw new JiveInstanceNotFoundException();
    } catch (Exception e) {
      logger.error("An error occurred getting access token", e);
      if (e instanceof JiveInstanceNotFoundException) throw (JiveInstanceNotFoundException)e;
      throw new JiveInstanceNotFoundException(e);
    }

    if (jiveInstance.getCredentials() == null || !StringUtils.hasText(jiveInstance.getCredentials().getAccessToken())) {
      // we don't have credentials yet, we need to request them using the code
      if (!StringUtils.hasText(jiveInstance.getCode())) throw new OAuthCodeNotFoundException();
      exchangeCodeForTokens(jiveInstance);
    }

    if (jiveInstance.getCredentials().isAccessTokenExpired()) {
      updateAccessToken(jiveInstance);
    }

    return jiveInstance.getCredentials().getAccessToken();
  }
View Full Code Here

Examples of com.ndriven.jive.cloud.examples.addon.model.JiveInstance

    @Path("/jive-instance-details")
    @Produces({"application/json;qs=1", "application/xml;qs=.5"})
    public String getJiveInstanceDetails() throws IOException, GeneralSecurityException {
        validateRequest();

        JiveInstance instance = instanceHolder.getJiveInstance();

        if (instance == null) {
            JSONObject responseObject = new JSONObject();
            responseObject.put("error", "The JiveInstance object is null.  The add-on has not been installed, or an error occurred during installation/registration.");
            return responseObject.toString();
View Full Code Here

Examples of com.ndriven.jive.cloud.examples.addon.model.JiveInstance

  @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
  @Produces(MediaType.TEXT_PLAIN)
  public String oauthCallback(@QueryParam("scope") String scope, @QueryParam("code") String code) throws IOException, GeneralSecurityException, JiveInstanceNotFoundException, OAuthCodeNotFoundException {
    logger.info(String.format("OAuth Callback: code=%s, scope=%s", code, scope));

    JiveInstance jiveInstance = jiveInstanceHolder.getJiveInstance();

    jiveInstance.setCode(code);
    jiveInstance.setScope(scope);
    jiveInstanceHolder.saveInstanceData();

    String errorMessage = "An error occurred authenticating with Jive.";
    try {
      String accessToken  = oAuthClient.getAccessToken();
View Full Code Here

Examples of com.ndriven.jive.cloud.examples.addon.model.JiveInstance

  @GET
        @Path("/oauth_url")
  @Produces(MediaType.TEXT_PLAIN)
  public String getAuthorizeUrl() throws IOException, GeneralSecurityException, JiveInstanceNotFoundException {
    JiveInstance jiveInstance = jiveInstanceHolder.getJiveInstance();

    if (jiveInstance == null) throw new JiveInstanceNotFoundException();

    String url = String.format(
        "%s/oauth2/authorize?client_id=%s&response_type=code",
        jiveInstance.getJiveUrl(),
        jiveInstance.getClientId()
      );

    return url;
  }
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.