Package com.ibm.sbt.security.credential.store

Examples of com.ibm.sbt.security.credential.store.CredentialStore


 

    private void readConsumerToken() throws OAuthException {
        if(!storeRead) {
          try {
            CredentialStore factory = CredentialStoreFactory.getCredentialStore(getCredentialStore());
              if(factory!=null) {
                ConsumerToken consumerToken = (ConsumerToken) factory.load(getServiceName(), CONSUMER_TOKEN_STORE_TYPE, null);
                  if(consumerToken!=null) {
                    storeRead = true;
                      if(StringUtil.isNotEmpty(consumerToken.getConsumerKey())) {
                          setConsumerKey(consumerToken.getConsumerKey());
                      }
View Full Code Here


            if(StringUtil.isEmpty(userId)) {
                return null;
            }
        }
        try {
          CredentialStore credStore = CredentialStoreFactory.getCredentialStore(getCredentialStore());
          if(credStore!=null) {
              // Find the token for this user
              AccessToken token = (AccessToken) credStore.load(getServiceName(), ACCESS_TOKEN_STORE_TYPE, userId);
              if(token!=null) {
                  return token;
              }
          }
        } catch (CredentialStoreException cse) {
View Full Code Here

    {
          AnonymousCredentialStore.deleteCredentials(context, getAppId(),getServiceName());
    }
        else {
           try {
               CredentialStore credStore = CredentialStoreFactory.getCredentialStore(getCredentialStore());
               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

          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) {
View Full Code Here

        }
        return renewedtoken;
    }
   
    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");
    }
View Full Code Here


  private void readConsumerToken() throws OAuthException {
    if (!storeRead) {
      try {
        CredentialStore factory = CredentialStoreFactory.getCredentialStore(getCredentialStore());
        if (factory != null) {
          ConsumerToken consumerToken = (ConsumerToken) factory.load(getServiceName(), CONSUMER_TOKEN_STORE_TYPE, null);
          if (consumerToken != null) {
            storeRead = true;
            if (StringUtil.isNotEmpty(consumerToken.getConsumerKey())) {
              setConsumerKey(consumerToken.getConsumerKey());
            }
View Full Code Here

      if (StringUtil.isEmpty(userId)) {
        return null;
      }
    }
    try {
      CredentialStore credStore = CredentialStoreFactory.getCredentialStore(getCredentialStore());
      if (credStore != null) {
        // Find the token for this user
        AccessToken token = (AccessToken) credStore.load(getServiceName(), ACCESS_TOKEN_STORE_TYPE, userId);
        if(token!=null) {
          return token;
        }
      }
    } catch (CredentialStoreException cse) {
View Full Code Here

    setAccessToken(token.getAccessToken());
    setAccessTokenSecret(token.getTokenSecret());
  }

  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");
    }
View Full Code Here

      getAccessTokenFromServer();

      token = createToken(getAppId(), getServiceName(), this, token.getUserId());
      setAccessTokenObject(token);
      if (!Context.get().isCurrentUserAnonymous()) {
        CredentialStore credStore = findCredentialStore();
        if (credStore != null) {
          try {
            // 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);
          } catch (CredentialStoreException cse) {
            throw new OAuthException(cse);
          }
        }
      } else {
View Full Code Here

    }
    if (StringUtil.equals(userId, "anonymous")) {
      AnonymousCredentialStore.deleteCredentials(context, getAppId(), getServiceName());
    } else {
      try {
        CredentialStore credStore = CredentialStoreFactory.getCredentialStore(getCredentialStore());
        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

TOP

Related Classes of com.ibm.sbt.security.credential.store.CredentialStore

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.