Package org.brickred.socialauth.util

Examples of org.brickred.socialauth.util.OAuthConfig


    domainMap.put(Constants.NIMBLE, "api.nimble.com");
    domainMap.put(Constants.LINKEDINOAUTH2, "api.linkedin.com");

    providersConfig = new HashMap<String, OAuthConfig>();

    OAuthConfig c = new OAuthConfig("openid", "openid");
    c.setProviderImplClass(org.brickred.socialauth.provider.OpenIdImpl.class);
    providersConfig.put(Constants.OPENID, c);

  }
View Full Code Here


          + ".consumer_secret");
      if (cKey != null && cSecret != null) {
        cKey = cKey.trim();
        cSecret = cSecret.trim();
        LOG.debug("Loading configuration for provider : " + key);
        OAuthConfig conf = new OAuthConfig(cKey, cSecret);
        conf.setId(key);
        conf.setProviderImplClass(providersImplMap.get(key));
        if (applicationProperties.containsKey(value
            + ".custom_permissions")) {
          String perms = applicationProperties.getProperty(
              value + ".custom_permissions").trim();
          if (perms.length() > 0) {
            conf.setCustomPermissions(perms);
          }
        }
        if (applicationProperties.containsKey(value
            + ".request_token_url")) {
          String reqUrl = applicationProperties.getProperty(
              value + ".request_token_url").trim();
          if (reqUrl.length() > 0) {
            conf.setRequestTokenUrl(reqUrl.trim());
          }
        }
        if (applicationProperties.containsKey(value
            + ".authentication_url")) {
          String authUrl = applicationProperties.getProperty(
              value + ".authentication_url").trim();
          if (authUrl.length() > 0) {
            conf.setAuthenticationUrl(authUrl.trim());
          }
        }
        if (applicationProperties.containsKey(value
            + ".access_token_url")) {
          String tokenUrl = applicationProperties.getProperty(
              value + ".access_token_url").trim();
          if (tokenUrl.length() > 0) {
            conf.setAccessTokenUrl(tokenUrl.trim());
          }
        }
        if (applicationProperties.containsKey(value + ".plugins")) {
          String pluginsStr = applicationProperties.getProperty(
              value + ".plugins").trim();
          if (pluginsStr.length() > 0) {
            String plugins[] = pluginsStr.split(",");
            if (plugins.length > 0) {
              List<String> pluginScopes = new ArrayList<String>();
              conf.setRegisteredPlugins(plugins);
              for (String plugin : plugins) {
                if (applicationProperties.containsKey(plugin
                    + ".scope")) {
                  String pscope = applicationProperties
                      .getProperty(plugin + ".scope")
                      .trim();
                  if (pscope.length() > 0) {
                    String sarr[] = pscope.split(",");
                    pluginScopes
                        .addAll(Arrays.asList(sarr));
                  }
                }
              }
              if (!pluginScopes.isEmpty()) {
                conf.setPluginsScopes(pluginScopes);
              }
            }
          }
        }
        providersConfig.put(key, conf);
View Full Code Here

   * @throws SocialAuthException
   * @throws SocialAuthConfigurationException
   */
  public OAuthConfig getProviderConfig(final String id)
      throws SocialAuthException, SocialAuthConfigurationException {
    OAuthConfig config = providersConfig.get(id);
    if (config == null) {
      try {
        new URL(id);
        config = getProviderConfig(Constants.OPENID);
        if (config != null) {
          config.setId(id);
        }
      } catch (MalformedURLException me) {
        throw new SocialAuthException(id
            + " is not a provider or valid OpenId URL");
      }
    }
    if (config == null) {
      throw new SocialAuthConfigurationException("Configuration of " + id
          + " provider is not found");
    }

    if (config.get_consumerSecret().length() <= 0) {
      throw new SocialAuthConfigurationException(id
          + " consumer_secret value is null");
    }
    if (config.get_consumerKey().length() <= 0) {
      throw new SocialAuthConfigurationException(id
          + " consumer_key value is null");
    }
    return config;
  }
View Full Code Here

    return providersMap.get(providerId);
  }

  private AuthProvider getProviderInstance(final String id)
      throws SocialAuthConfigurationException, SocialAuthException {
    OAuthConfig config = socialAuthConfig.getProviderConfig(id);
    Class<?> obj = config.getProviderImplClass();
    AuthProvider provider;
    try {
      Constructor<?> cons = obj.getConstructor(OAuthConfig.class);
      provider = (AuthProvider) cons.newInstance(config);
    } catch (NoSuchMethodException me) {
View Full Code Here

  private static AuthProvider loadProvider(final String id,
      final Properties props) throws Exception {
    Class<?> obj = providerMap.get(id);
    props.setProperty("id", id);
    AuthProvider provider;
    OAuthConfig conf;

    if (obj == null) {
      try {
        new URL(id); // just validating, don't need the value
        obj = providerMap.get("openid");
        conf = new OAuthConfig(null, null);
        conf.setId(id);
      } catch (MalformedURLException me) {
        throw new SocialAuthException(id
            + " is not a provider or valid OpenId URL");
      }
    } else {
      String key;
      if (domainMap.containsKey(id)) {
        key = domainMap.get(id);
      } else {
        key = id;
      }
      String consumerKey = props.getProperty(key + ".consumer_key");
      if (consumerKey == null) {
        throw new IllegalStateException(key
            + ".consumer_key not found.");
      }

      String consumerSecret = props.getProperty(key + ".consumer_secret");
      if (consumerSecret == null) {
        throw new IllegalStateException(key
            + ".consumer_secret not found.");
      }
      conf = new OAuthConfig(consumerKey, consumerSecret);
      conf.setId(id);
    }

    try {
      Constructor<?> cons = obj.getConstructor(OAuthConfig.class);
      provider = (AuthProvider) cons.newInstance(conf);
View Full Code Here

TOP

Related Classes of org.brickred.socialauth.util.OAuthConfig

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.