Package org.apache.shindig.gadgets.oauth2.persistence

Examples of org.apache.shindig.gadgets.oauth2.persistence.OAuth2PersistenceException


        }

        try {
          client.setEncryptedSecret(secret.getBytes("UTF-8"));
        } catch (final OAuth2EncryptionException e) {
          throw new OAuth2PersistenceException(e);
        }

        client.setClientId(clientId);

        if (this.authority != null) {
          redirectUri = redirectUri.replace("%authority%", this.authority.getAuthority());
          redirectUri = redirectUri.replace("%contextRoot%", this.contextRoot);
          redirectUri = redirectUri.replace("%origin%", this.authority.getOrigin());
          redirectUri = redirectUri.replace("%scheme", this.authority.getScheme());
        }
        client.setRedirectUri(redirectUri);

        if (grantType == null || grantType.length() == 0) {
          grantType = OAuth2Message.AUTHORIZATION;
        }

        client.setGrantType(grantType);

        OAuth2Accessor.Type type = OAuth2Accessor.Type.UNKNOWN;
        if (OAuth2Message.CONFIDENTIAL_CLIENT_TYPE.equals(typeS)) {
          type = OAuth2Accessor.Type.CONFIDENTIAL;
        } else if (OAuth2Message.PUBLIC_CLIENT_TYPE.equals(typeS)) {
          type = OAuth2Accessor.Type.PUBLIC;
        }
        client.setType(type);

        final JSONArray dArray = settings.optJSONArray(JSONOAuth2Persister.ALLOWED_DOMAINS);
        if (dArray != null) {
          final ArrayList<String> domains = new ArrayList<String>();
          for (int i = 0; i < dArray.length(); i++) {
            domains.add(dArray.optString(i));
          }
          client.setAllowedDomains(domains.toArray(new String[0]));
        }

        internalMap.put(clientName, client);
      }
    } catch (final Exception e) {
      if (JSONOAuth2Persister.LOG.isLoggable()) {
        JSONOAuth2Persister.LOG.log("OAuth2PersistenceException", e);
      }
      throw new OAuth2PersistenceException(e);
    }

    final Set<OAuth2Client> ret = new HashSet<OAuth2Client>(gadgetBindings.size());
    for (final OAuth2GadgetBinding binding : gadgetBindings.values()) {
      final String clientName = binding.getClientName();
View Full Code Here


    } catch (final JSONException e) {
      if (JSONOAuth2Persister.LOG.isLoggable()) {
        JSONOAuth2Persister.LOG.log("OAuth2PersistenceException", e);
      }
      throw new OAuth2PersistenceException(e);
    }

    return ret;
  }
View Full Code Here

      }
    } catch (final JSONException e) {
      if (JSONOAuth2Persister.LOG.isLoggable()) {
        JSONOAuth2Persister.LOG.log("OAuth2PersistenceException", e);
      }
      throw new OAuth2PersistenceException(e);
    }

    return ret;
  }
View Full Code Here

        }

        try {
          client.setEncryptedSecret(secret.getBytes("UTF-8"));
        } catch (final OAuth2EncryptionException e) {
          throw new OAuth2PersistenceException(e);
        }

        client.setClientId(clientId);

        if (this.authority != null) {
          redirectUri = redirectUri.replace("%authority%", this.authority.getAuthority());
          redirectUri = redirectUri.replace("%contextRoot%", this.contextRoot);
          redirectUri = redirectUri.replace("%origin%", this.authority.getOrigin());
          redirectUri = redirectUri.replace("%scheme", this.authority.getScheme());
        }
        client.setRedirectUri(redirectUri);

        if (grantType == null || grantType.length() == 0) {
          grantType = OAuth2Message.AUTHORIZATION;
        }

        client.setGrantType(grantType);

        OAuth2Accessor.Type type = OAuth2Accessor.Type.UNKNOWN;
        if (OAuth2Message.CONFIDENTIAL_CLIENT_TYPE.equals(typeS)) {
          type = OAuth2Accessor.Type.CONFIDENTIAL;
        } else if (OAuth2Message.PUBLIC_CLIENT_TYPE.equals(typeS)) {
          type = OAuth2Accessor.Type.PUBLIC;
        }
        client.setType(type);

        final JSONArray dArray = settings.optJSONArray(ALLOWED_DOMAINS);
        if (dArray != null) {
          final ArrayList<String> domains = new ArrayList<String>();
          for (int i = 0; i < dArray.length(); i++) {
            domains.add(dArray.optString(i));
          }
          client.setAllowedDomains(domains.toArray(new String[domains.size()]));
        }

        internalMap.put(clientName, client);
      }
    } catch (RuntimeException e) {
      throw e; 
    } catch (final Exception e) {
      LOG.logp(Level.WARNING, CLAZZ, method, "Exception loading clients.", e);
      throw new OAuth2PersistenceException(e);
    }
   
    final Set<OAuth2Client> ret = new HashSet<OAuth2Client>(gadgetBindings.size());
    for (final OAuth2GadgetBinding binding : gadgetBindings.values()) {
      final String clientName = binding.getClientName();
View Full Code Here

      }


    } catch (final JSONException e) {
      LOG.logp(Level.WARNING, CLAZZ, method, "Exception while loading gadget bindings.", e);
      throw new OAuth2PersistenceException(e);
    }

    return ret;
  }
View Full Code Here

        ret.put(oauth2Provider.getName(), oauth2Provider);
      }
    } catch (final JSONException e) {
      LOG.logp(Level.WARNING, CLAZZ, method, "Exception parsing providers.", e);
      throw new OAuth2PersistenceException(e);
    }

    return ret;
  }
View Full Code Here

  }

  protected static OAuth2Store getDummyStore() throws Exception {
    if (MockUtils.dummyStore == null) {
      final OAuth2Cache cache = new InMemoryCache();
      final OAuth2Persister persister = MockUtils.getDummyPersister();
      MockUtils.dummyStore = MockUtils.getDummyStore(cache, persister, MockUtils.REDIRECT_URI);
    }

    MockUtils.dummyStore.clearCache();
    MockUtils.dummyStore.init();
View Full Code Here

    return accessToken;
  }

  private static BasicOAuth2Accessor getOAuth2AccessorCommon() throws Exception {
    final OAuth2Cache cache = new InMemoryCache();
    final OAuth2Persister persister = MockUtils.getDummyPersister();
    final OAuth2Store store = MockUtils.getDummyStore(cache, persister, MockUtils.REDIRECT_URI);
    final BasicOAuth2Accessor accessor = new BasicOAuth2Accessor(MockUtils.GADGET_URI1,
        MockUtils.SERVICE_NAME, MockUtils.USER, MockUtils.SCOPE, true, store,
        MockUtils.REDIRECT_URI);
View Full Code Here

    return accessor;
  }

  protected static OAuth2Accessor getOAuth2Accessor_ClientCredentialsRedirecting() throws Exception {
    final OAuth2Cache cache = new InMemoryCache();
    final OAuth2Persister persister = MockUtils.getDummyPersister();
    final OAuth2Store store = MockUtils.getDummyStore(cache, persister, MockUtils.REDIRECT_URI);
    final BasicOAuth2Accessor accessor = new BasicOAuth2Accessor(MockUtils.GADGET_URI1,
        MockUtils.SERVICE_NAME, MockUtils.USER, MockUtils.SCOPE, true, store,
        MockUtils.REDIRECT_URI);
View Full Code Here

      this.store = new BasicOAuth2Store(cache, persister, redirectUri);

      if (importFromConfig) {
        try {
          final OAuth2Persister source = new JSONOAuth2Persister(encrypter, authority,
                  globalRedirectUri, contextRoot);
          BasicOAuth2Store.runImport(source, persister, importClean);
        } catch (final OAuth2PersistenceException e) {
          if (OAuth2Module.LOG.isLoggable()) {
            OAuth2Module.LOG.log("store init exception", e);
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.oauth2.persistence.OAuth2PersistenceException

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.