/*
   * (non-Javadoc)
   * @see com.socialize.SocializeService#isAuthenticated(com.socialize.auth.AuthProviderType)
   */
  @Override
  public boolean isAuthenticated(AuthProviderType providerType) {
    if (isAuthenticated()) {

      if (providerType.equals(AuthProviderType.SOCIALIZE)) {
        return true;
      }

      UserProviderCredentials userProviderCredentials =
          session.getUserProviderCredentials(providerType);

      if (userProviderCredentials != null) {
        // Validate the credentials
        AuthProviderInfo authProviderInfo = userProviderCredentials.getAuthProviderInfo();

        if (authProviderInfo != null) {
          AuthProvider<AuthProviderInfo> provider = authProviders.getProvider(providerType);

          boolean valid = provider.validate(authProviderInfo);

          return valid;
        }

        return false;
      }
    }

    return false;
  }
  @SuppressWarnings("deprecation")
  public boolean validateSessionAuthDataLegacy(SocializeSession loaded, AuthProviderData data) {

    if (data.getAuthProviderType().equals(AuthProviderType.SOCIALIZE)) {
      return true;
    }

    if (data.getAuthProviderType() != null && !StringUtils.isEmpty(data.getAppId3rdParty())) {
      AuthProviderType loadedAuthProviderType = loaded.getAuthProviderType();
      String loadedAppId3rdParty = loaded.get3rdPartyAppId();

      if (loadedAuthProviderType != null
          && !StringUtils.isEmpty(loadedAppId3rdParty)
          && loadedAuthProviderType.equals(data.getAuthProviderType())
          && loadedAppId3rdParty.equals(data.getAppId3rdParty())) {
        return true;
      }
    }

    return false;
  }