All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.clouway.oauth2.client.ClientRegistryImpl Maven / Gradle / Ivy

There is a newer version: 1.0.6
Show newest version
package com.clouway.oauth2.client;

import com.clouway.oauth2.token.TokenGenerator;

/**
 * @author Mihail Lesikov ([email protected])
 */
class ClientRegistryImpl implements ClientRegistry {

  private TokenGenerator tokenGenerator;
  private ClientRepository repository;

  public ClientRegistryImpl(TokenGenerator tokenGenerator, ClientRepository repository) {
    this.tokenGenerator = tokenGenerator;
    this.repository = repository;
  }

  @Override
  public RegistrationResponse register(RegistrationRequest request) throws ClientAlreadyExistsException {
    String id = tokenGenerator.generate();
    String secret = tokenGenerator.generate();

    Client client = new Client(id, secret, request.name, request.url, request.description, request.redirectURI);

    repository.register(client);

    return new RegistrationResponse(id, secret);
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy