Package com.ibm.sbt.security.authentication.oauth

Examples of com.ibm.sbt.security.authentication.oauth.OAuthException


        responseBody = StreamUtil.readString(reader);
      } finally {
        StreamUtil.close(reader);
      }
    } catch (Exception e) {
      throw new OAuthException(e, "getAccessToken failed with Exception: <br>" + e);
    } finally {
      if(content != null) {
        content.close();
      }
    }
View Full Code Here


        responseBody = StreamUtil.readString(reader);
      } finally {
        StreamUtil.close(reader);
      }
    } catch (Exception e) {
      throw new OAuthException(e,"getAccessToken failed with Exception: <br>");
    } finally {
      if(content!=null) {
        content.close();
      }
    }
    if (responseCode != HttpStatus.SC_OK) {
      String exceptionDetail = buildErrorMessage(responseCode, responseBody);
      if (exceptionDetail != null) {
        String msg = "Unable to retrieve access token because \"{0}\". Please check the access token URL is valid, current value: {1}.";
        msg = MessageFormat.format(msg, exceptionDetail, getAccessTokenURL());
        throw new OAuthException(null, msg);
      }
    } else {
      setOAuthData(responseBody); //save the returned data
    }
  }
View Full Code Here

                          setAccessTokenURL(consumerToken.getAccessTokenUri());
                      }                  
                  }
              }
          } catch (CredentialStoreException cse) {
          throw new OAuthException(cse, cse.getMessage());
      }
        }
    }
View Full Code Here

              if(token!=null) {
                  return token;
              }
          }
        } catch (CredentialStoreException cse) {
        throw new OAuthException(cse, "Error finding credentials from the store");
    }
        return null;
    }
View Full Code Here

               if(credStore!=null) {
                 // Find the token for this user
                 credStore.remove(getServiceName(), ACCESS_TOKEN_STORE_TYPE, getUserId());
               }
           } catch (CredentialStoreException cse) {
         throw new OAuthException(cse, "Error trying to delete Token.");
       }
        }
    }
View Full Code Here

            responseBody = StreamUtil.readString(reader);
          } finally {
            StreamUtil.close(reader);
          }
        } catch (Exception e) {
          throw new OAuthException(e ,"refreshAccessToken failed with Exception: <br>" + e);
        } finally {
          if (method != null){
          try {
            if(content!=null) {
              content.close();
            }
          } catch (IOException e) {
            throw new OAuthException(e ,"refreshAccessToken failed with Exception: <br>" + e);
          }
          }
        }
        if (responseCode != HttpStatus.SC_OK) {
            acquireToken(true, true); // Failed to renew token, get a new one
                  return null;
        } else {
          setOAuthData(responseBody);
          renewedtoken = createToken(getAppId(),getServiceName()); // Now create a new token and save that in the store       
          Context context = Context.get();
          setAccessTokenObject(renewedtoken);
          try {
                if(!context.isCurrentUserAnonymous()) {
                  CredentialStore credStore = findCredentialStore();
                  if (credStore != null) {
                // if the token is already present, and was expired due to which we have fetched a new
                // token, then we remove the token from the store first and then add this new token.
                deleteToken();
                credStore.store(getServiceName(), ACCESS_TOKEN_STORE_TYPE, getUserId(), token);
              }
                  } else {
                    AnonymousCredentialStore.storeCredentials(context, token, getAppId(), getServiceName()); // Store the token for anonymous user
                  }
          } catch (CredentialStoreException cse) {
            throw new OAuthException(cse, "Error trying to renew Token.");
          }
        }
        return renewedtoken;
    }
View Full Code Here

    public CredentialStore findCredentialStore() throws OAuthException {
      CredentialStore credStore = null;
    try {
      credStore = CredentialStoreFactory.getCredentialStore(getCredentialStore());
    } catch (CredentialStoreException cse) {
      throw new OAuthException(cse, "Error finding credentials from the store");
    }
    return credStore;
    }
View Full Code Here

    public boolean shouldRenewToken(AccessToken token) throws OAuthException {
        // We do not automatically renew/acquire it - we just get it from the store
       if(token==null) {
            token = _findTokenFromStore(Context.get(), null);
            if(token==null) {
                throw new OAuthException(null,"No user token is available");
            }
        }
        return token.isExpired(getExpireThreshold());
    }
View Full Code Here

                        getUserId(),
                        expiresIn,
                        getRefreshToken()
            );
        } catch (Exception e) {
            throw new OAuthException(e);
        }
    }
View Full Code Here

        responseBody = StreamUtil.readString(reader);
      } finally {
        StreamUtil.close(reader);
      }
    } catch (Exception e) {
      throw new OAuthException(e, "Internal error - getRequestToken failed Exception: <br>");
    } finally {
      if(content!=null) {
        content.close();
      }
    }
    if (responseCode != HttpStatus.SC_OK) {
      String exceptionDetail = buildErrorMessage(responseCode, responseBody);
      if (exceptionDetail != null) {
        throw new OAuthException(null,
            "OAuth1Handler.java : getRequestToken failed. " + exceptionDetail);
      }
    } else {
      setRequestToken(getTokenValue(responseBody, Configuration.OAUTH_TOKEN));
      setRequestTokenSecret(getTokenValue(responseBody, Configuration.OAUTH_TOKEN_SECRET));
View Full Code Here

TOP

Related Classes of com.ibm.sbt.security.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.