@Test public void updateClient_yesOfflineAccess() { ClientDetailsEntity oldClient = new ClientDetailsEntity(); ClientDetailsEntity client = new ClientDetailsEntity(); Set<String> grantTypes = new HashSet<>(); grantTypes.add("refresh_token"); client.setGrantTypes(grantTypes); client = service.updateClient(oldClient, client); Mockito.verify(scopeService, Mockito.atLeastOnce()).removeReservedScopes(Matchers.anySet()); assertThat(client.getScope().contains(SystemScopeService.OFFLINE_ACCESS), is(equalTo(true))); }
@Override public ClientDetailsEntity updateClient(ClientDetailsEntity oldClient, ClientDetailsEntity newClient) throws IllegalArgumentException { if (oldClient != null && newClient != null) { for (String uri : newClient.getRegisteredRedirectUri()) { if (blacklistedSiteService.isBlacklisted(uri)) { throw new IllegalArgumentException("Client URI is blacklisted: " + uri); } } ensureRefreshTokenConsistency(newClient); ensureKeyConsistency(newClient); checkHeartMode(newClient); checkSectorIdentifierUri(newClient); ensureNoReservedScopes(newClient); return clientRepository.updateClient(oldClient.getId(), newClient); } throw new IllegalArgumentException("Neither old client or new client can be null!"); }
DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEntityService { @Override public ClientDetailsEntity updateClient(ClientDetailsEntity oldClient, ClientDetailsEntity newClient) throws IllegalArgumentException { if (oldClient != null && newClient != null) { for (String uri : newClient.getRegisteredRedirectUri()) { if (blacklistedSiteService.isBlacklisted(uri)) { throw new IllegalArgumentException("Client URI is blacklisted: " + uri); } } ensureRefreshTokenConsistency(newClient); ensureKeyConsistency(newClient); checkHeartMode(newClient); checkSectorIdentifierUri(newClient); ensureNoReservedScopes(newClient); return clientRepository.updateClient(oldClient.getId(), newClient); } throw new IllegalArgumentException("Neither old client or new client can be null!"); } }
DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEntityService { @Override public ClientDetailsEntity updateClient(ClientDetailsEntity oldClient, ClientDetailsEntity newClient) throws IllegalArgumentException { if (oldClient != null && newClient != null) { for (String uri : newClient.getRegisteredRedirectUri()) { if (blacklistedSiteService.isBlacklisted(uri)) { throw new IllegalArgumentException("Client URI is blacklisted: " + uri); } } ensureRefreshTokenConsistency(newClient); ensureKeyConsistency(newClient); checkHeartMode(newClient); checkSectorIdentifierUri(newClient); ensureNoReservedScopes(newClient); return clientRepository.updateClient(oldClient.getId(), newClient); } throw new IllegalArgumentException("Neither old client or new client can be null!"); }  }
DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEntityService { @Override public ClientDetailsEntity updateClient(ClientDetailsEntity oldClient, ClientDetailsEntity newClient) throws IllegalArgumentException { if (oldClient != null && newClient != null) { for (String uri : newClient.getRegisteredRedirectUri()) { if (blacklistedSiteService.isBlacklisted(uri)) { throw new IllegalArgumentException("Client URI is blacklisted: " + uri); } } ensureRefreshTokenConsistency(newClient); ensureKeyConsistency(newClient); checkHeartMode(newClient); checkSectorIdentifierUri(newClient); ensureNoReservedScopes(newClient); return clientRepository.updateClient(oldClient.getId(), newClient); } throw new IllegalArgumentException("Neither old client or new client can be null!"); }  @Override ClientDetailsEntity saveNewClient(ClientDetailsEntity client); @Override ClientDetailsEntity getClientById(Long id); @Override ClientDetailsEntity loadClientByClientId(String clientId); @Override void deleteClient(ClientDetailsEntity client); @Override ClientDetailsEntity updateClient(ClientDetailsEntity oldClient, ClientDetailsEntity newClient); @Override Collection<ClientDetailsEntity> getAllClients(); @Override ClientDetailsEntity generateClientId(ClientDetailsEntity client); @Override ClientDetailsEntity generateClientSecret(ClientDetailsEntity client); }
DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEntityService { @Override public ClientDetailsEntity updateClient(ClientDetailsEntity oldClient, ClientDetailsEntity newClient) throws IllegalArgumentException { if (oldClient != null && newClient != null) { for (String uri : newClient.getRegisteredRedirectUri()) { if (blacklistedSiteService.isBlacklisted(uri)) { throw new IllegalArgumentException("Client URI is blacklisted: " + uri); } } ensureRefreshTokenConsistency(newClient); ensureKeyConsistency(newClient); checkHeartMode(newClient); checkSectorIdentifierUri(newClient); ensureNoReservedScopes(newClient); return clientRepository.updateClient(oldClient.getId(), newClient); } throw new IllegalArgumentException("Neither old client or new client can be null!"); }  @Override ClientDetailsEntity saveNewClient(ClientDetailsEntity client); @Override ClientDetailsEntity getClientById(Long id); @Override ClientDetailsEntity loadClientByClientId(String clientId); @Override void deleteClient(ClientDetailsEntity client); @Override ClientDetailsEntity updateClient(ClientDetailsEntity oldClient, ClientDetailsEntity newClient); @Override Collection<ClientDetailsEntity> getAllClients(); @Override ClientDetailsEntity generateClientId(ClientDetailsEntity client); @Override ClientDetailsEntity generateClientSecret(ClientDetailsEntity client);  }