package com.eactive.eai.authserver.service;

import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.security.oauth2.provider.ClientRegistrationException;
import org.springframework.security.oauth2.provider.NoSuchClientException;
import org.springframework.stereotype.Service;

@Service("eLinkClientDetailsService")
public class ElinkClientDetailsServiceImpl implements ClientDetailsService {

	@Override
	public ClientDetails loadClientByClientId(String clientId) throws ClientRegistrationException {
		ClientDetails details = OAuth2Manager.getInstance().getClientDeatilsStore().get(clientId);
		if (details == null) {
			throw new NoSuchClientException("No client with requested id: " + clientId);
		}
		return details;
	}
}
