class CredentialProviderRegistry implements CredentialProviderLocator {

    @Override
    public CredentialProvider providerWithId(final String providerId) {
        final Connector connector = dataManager.fetch(Connector.class, providerId);

        if (connector == null) {
            throw new IllegalArgumentException("Unable to find connector with id: " + providerId);
        }

        final String providerToUse = determineProviderFrom(connector);

        final CredentialProviderFactory credentialProviderFactory = credentialProviderFactories.get(providerToUse);
        if (credentialProviderFactory == null) {
            throw new IllegalArgumentException("Unable to locate credential provider factory with id: " + providerId);
        }

        final SocialProperties socialProperties = createSocialProperties(providerToUse, connector);
        final CredentialProvider providerWithId = credentialProviderFactory.create(socialProperties);

        if (providerWithId == null) {
            throw new IllegalArgumentException("Unable to locate credential provider with id: " + providerId);
        }

        return providerWithId;
    }

      CredentialProviderRegistry(final DataManager dataManager);

}