List of usage examples for org.springframework.security.oauth2.provider NoSuchClientException NoSuchClientException
public NoSuchClientException(String msg)
From source file:com.cosw.productsmaster.authsec.GuestServiceImpl.java
@Override public ClientDetails loadClientByClientId(String clientId) throws ClientRegistrationException { if (clientId.equals(id)) { List<String> authorizedGrantTypes = new ArrayList<String>(); authorizedGrantTypes.add("password"); authorizedGrantTypes.add("refresh_token"); authorizedGrantTypes.add("client_credentials"); BaseClientDetails clientDetails = new BaseClientDetails(); clientDetails.setClientId(id);//from www . java2 s . c o m clientDetails.setClientSecret(secretKey); clientDetails.setAuthorizedGrantTypes(authorizedGrantTypes); return clientDetails; } else { throw new NoSuchClientException("No client recognized with id: " + clientId); } }
From source file:com.tlantic.integration.authentication.service.security.ClientDetailService.java
@Override public void updateClientDetails(ClientDetails cd) throws NoSuchClientException { ClientDetail clientDetails = clientDetailsRepository.findByClientId(cd.getClientId()); if (null == clientDetails) { throw new NoSuchClientException("Client not found with ID '" + cd.getClientId() + "'"); }// w w w .jav a 2 s .c o m clientDetails = getMongoDBClientDetailsFromClient(cd); clientDetailsRepository.save(clientDetails); }
From source file:org.openmhealth.dsu.service.SpringDataClientRegistrationServiceImpl.java
@Override @Transactional/*from w w w .ja v a2s .c o m*/ public void updateClientDetails(ClientDetails clientDetails) throws NoSuchClientException { if (!repository.findOne(clientDetails.getClientId()).isPresent()) { throw new NoSuchClientException( format("A client with id '%s' wasn't found.", clientDetails.getClientId())); } repository.save(new SimpleClientDetails(clientDetails)); }
From source file:com.tlantic.integration.authentication.service.security.ClientDetailService.java
@Override public void updateClientSecret(String clientId, String secret) throws NoSuchClientException { ClientDetail clientDetails = clientDetailsRepository.findByClientId(clientId); if (null == clientDetails) { throw new NoSuchClientException("Client not found with ID '" + clientId + "'"); }// w w w.j a v a 2s . c o m clientDetails.setClientSecret(passwordEncoder.encode(secret)); clientDetailsRepository.save(clientDetails); }
From source file:ru.ttk.baloo.rest.security.oauth.SimpleClientDetailsService.java
@Override public ClientDetails loadClientByClientId(String clientId) throws OAuth2Exception { if (StringUtils.isNotBlank(clientId)) { IRemoteUser remoteUser = remoteUserFinder.findUser(clientId); if (remoteUser != null) { // List<String> authorizedGrantTypes = Arrays.asList("password", "refresh_token", "client_credentials"); List<String> authorizedGrantTypes = Arrays.asList("password", "refresh_token"); BaseClientDetails clientDetails = new BaseClientDetails(); // in our case username <=> clientId and clientSecret <=> password clientDetails.setClientId(remoteUser.getUserName()); clientDetails.setClientSecret(remoteUser.getPassword()); clientDetails.setAuthorizedGrantTypes(authorizedGrantTypes); return clientDetails; }//from w ww .j av a2 s. c o m } LOG.warn("No client with requested id: " + clientId); throw new NoSuchClientException("No client with requested id: " + clientId); }
From source file:org.openmhealth.dsu.service.SpringDataClientRegistrationServiceImpl.java
@Override @Transactional//from w w w . j a va 2 s .co m public void updateClientSecret(String clientId, String secret) throws NoSuchClientException { SimpleClientDetails clientDetails = repository.findOne(clientId).orElseThrow( () -> new NoSuchClientException(format("A client with id '%s' wasn't found.", clientId))); clientDetails.setClientSecret(secret); repository.save(clientDetails); }
From source file:com.mycompany.apps.oauth2.authentication.security.ClientDetailsServiceImpl.java
@Override public ClientDetails loadClientByClientId(String clientId) throws OAuth2Exception { if (clientId.equals("client1")) { List<String> authorizedGrantTypes = new ArrayList<>(); authorizedGrantTypes.add("password"); authorizedGrantTypes.add("refresh_token"); authorizedGrantTypes.add("client_credentials"); BaseClientDetails clientDetails = new BaseClientDetails(); clientDetails.setClientId("client1"); clientDetails.setClientSecret("client1"); clientDetails.setAuthorizedGrantTypes(authorizedGrantTypes); return clientDetails; } else if (clientId.equals("client2")) { List<String> authorizedGrantTypes = new ArrayList<>(); authorizedGrantTypes.add("password"); authorizedGrantTypes.add("refresh_token"); authorizedGrantTypes.add("client_credentials"); BaseClientDetails clientDetails = new BaseClientDetails(); clientDetails.setClientId("client2"); clientDetails.setClientSecret("client2"); clientDetails.setAuthorizedGrantTypes(authorizedGrantTypes); return clientDetails; } else {//from w ww . j ava 2 s.com throw new NoSuchClientException("No client with requested id: " + clientId); } }
From source file:com.tlantic.integration.authentication.service.security.ClientDetailService.java
@Override public void removeClientDetails(String clientId) throws NoSuchClientException { ClientDetail clientDetails = clientDetailsRepository.findByClientId(clientId); if (null == clientDetails) { throw new NoSuchClientException("Client not found with ID '" + clientId + "'"); }/*from www .j a v a 2s.c om*/ clientDetailsRepository.delete(clientDetails); }
From source file:org.openmhealth.dsu.service.SpringDataClientRegistrationServiceImpl.java
@Override @Transactional// w w w . j ava2s. c o m public void removeClientDetails(String clientId) throws NoSuchClientException { if (!repository.findOne(clientId).isPresent()) { throw new NoSuchClientException(format("A client with id '%s' wasn't found.", clientId)); } repository.delete(clientId); }
From source file:oauth2.authentication.clients.ClientServiceImpl.java
@Override public ClientDetails loadClientByClientId(String clientId) { Client client = clientRepository.findByClientId(clientId); if (client == null) { throw new NoSuchClientException("No client with requested id: " + clientId); }//from w w w . j a v a2 s.c o m ClientDetailsBuilder builder = new ClientDetailsBuilder() // .clientId(client.getClientId()) // .clientSecret(client.getClientSecret()) // .accessTokenValiditySeconds(client.getAccessTokenValidity()) // .refreshTokenValiditySeconds(client.getRefreshTokenValidity()); client.getEntries().stream().forEach(mapEntry(builder)); return builder.build(); }