本文整理汇总了Java中org.springframework.security.oauth2.provider.NoSuchClientException类的典型用法代码示例。如果您正苦于以下问题:Java NoSuchClientException类的具体用法?Java NoSuchClientException怎么用?Java NoSuchClientException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NoSuchClientException类属于org.springframework.security.oauth2.provider包,在下文中一共展示了NoSuchClientException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadClientByClientId
import org.springframework.security.oauth2.provider.NoSuchClientException; //导入依赖的package包/类
@Override
public ClientDetails loadClientByClientId(String clientId) throws ClientRegistrationException {
Client client = this.clientRepository.findByClientId(clientId);
if (client == null) {
throw new NoSuchClientException(String.format("No client with requested id: %s", clientId));
}
BaseClientDetails baseClientDetails = new BaseClientDetails();
baseClientDetails.setClientId(client.getClientId());
baseClientDetails.setClientSecret(client.getClientSecret());
baseClientDetails.setResourceIds(StringUtils.commaDelimitedListToSet(client.getResourceIds()));
baseClientDetails.setScope(StringUtils.commaDelimitedListToSet(client.getScopes()));
baseClientDetails.setAuthorizedGrantTypes(StringUtils.commaDelimitedListToSet(client.getGrantTypes()));
baseClientDetails.setRegisteredRedirectUri(StringUtils.commaDelimitedListToSet(client.getRedirectUris()));
baseClientDetails.setAutoApproveScopes(StringUtils.commaDelimitedListToSet(client.getAutoApproveScopes()));
return baseClientDetails;
}
示例2: loadClientByClientId
import org.springframework.security.oauth2.provider.NoSuchClientException; //导入依赖的package包/类
@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);
clientDetails.setClientSecret(secretKey);
clientDetails.setAuthorizedGrantTypes(authorizedGrantTypes);
return clientDetails;
}
else {
throw new NoSuchClientException("No client recognized with id: "
+ clientId);
}
}
示例3: updateClientDetails
import org.springframework.security.oauth2.provider.NoSuchClientException; //导入依赖的package包/类
@Override
public void updateClientDetails(ClientDetails clientDetails) throws NoSuchClientException {
final MongoClientDetails mongoClientDetails = new MongoClientDetails(clientDetails.getClientId(),
clientDetails.getClientSecret(),
clientDetails.getScope(),
clientDetails.getResourceIds(),
clientDetails.getAuthorizedGrantTypes(),
clientDetails.getRegisteredRedirectUri(),
newArrayList(clientDetails.getAuthorities()),
clientDetails.getAccessTokenValiditySeconds(),
clientDetails.getRefreshTokenValiditySeconds(),
clientDetails.getAdditionalInformation(),
getAutoApproveScopes(clientDetails));
final boolean result = mongoClientDetailsRepository.update(mongoClientDetails);
if (!result) {
throw new NoSuchClientException("No such Client Id");
}
}
示例4: loadClientByClientId
import org.springframework.security.oauth2.provider.NoSuchClientException; //导入依赖的package包/类
@Override
public ClientDetails loadClientByClientId(String clientId)
throws ClientRegistrationException {
if(clientId.equals("353b302c44574f565045687e534e7d6a")){
List<String> authorizedGrantTypes = new ArrayList<String>();
authorizedGrantTypes.add("password");
authorizedGrantTypes.add("refresh_token");
BaseClientDetails clientDetails = new BaseClientDetails();
clientDetails.setClientId("353b302c44574f565045687e534e7d6a");
clientDetails.setClientSecret("286924697e615a672a646a493545646c");
clientDetails.setAuthorizedGrantTypes(authorizedGrantTypes);
List<String> list = new ArrayList<String>();
list.add("read");
list.add("write");
clientDetails.setScope(list);
return clientDetails;
}else{
throw new NoSuchClientException("No client with requested id:");
}
}
示例5: shouldUpdateClientSecret
import org.springframework.security.oauth2.provider.NoSuchClientException; //导入依赖的package包/类
@Test
public void shouldUpdateClientSecret() throws NoSuchClientException {
//Given
final String clientId = string().next();
final String secret = string().next();
//And
final String expectedNewSecret = string().next();
given(passwordEncoder.encode(secret)).willReturn(expectedNewSecret);
//And
given(mongoClientDetailsRepository.updateClientSecret(clientId, expectedNewSecret)).willReturn(true);
//When
mongoClientDetailsService.updateClientSecret(clientId, secret);
}
示例6: shouldNotUpdateClientSecretWhenClientIdIsInvalid
import org.springframework.security.oauth2.provider.NoSuchClientException; //导入依赖的package包/类
@Test(expected = NoSuchClientException.class)
public void shouldNotUpdateClientSecretWhenClientIdIsInvalid() throws NoSuchClientException {
//Given
final String clientId = string().next();
final String secret = string().next();
//And
final String expectedNewSecret = string().next();
given(passwordEncoder.encode(secret)).willReturn(expectedNewSecret);
//And
given(mongoClientDetailsRepository.updateClientSecret(clientId, expectedNewSecret)).willReturn(false);
//When
mongoClientDetailsService.updateClientSecret(clientId, secret);
}
示例7: loadClientByClientId
import org.springframework.security.oauth2.provider.NoSuchClientException; //导入依赖的package包/类
@Override
public ClientDetails loadClientByClientId(String clientId)
throws OAuth2Exception {
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);
clientDetails.setClientSecret(secretKey);
clientDetails.setAuthorizedGrantTypes(authorizedGrantTypes);
return clientDetails;
}
else {
throw new NoSuchClientException("No client recognized with id: "
+ clientId);
}
}
示例8: delete
import org.springframework.security.oauth2.provider.NoSuchClientException; //导入依赖的package包/类
@RequestMapping(path = "/_remove/{clientId}", method = RequestMethod.GET, produces = { MediaType.TEXT_HTML_VALUE,
MediaType.APPLICATION_XHTML_XML_VALUE })
public String delete(@PathVariable("clientId") String clientId, RedirectAttributes attributes) {
try {
clientDetailsService.removeClientDetails(clientId);
} catch (NoSuchClientException e) {
addWarningMessage(attributes, "没有找到客户端ID " + clientId + " 对应的客户端。");
}
return "redirect:/clientDetails.html";
}
示例9: updateClientSecret
import org.springframework.security.oauth2.provider.NoSuchClientException; //导入依赖的package包/类
@Transactional
@Override
public void updateClientSecret(String clientId, String secret) throws NoSuchClientException {
ClientDetailsEntity clientDetailsEntity = clientDetailsRepository.findOneByClientId(clientId).<NoSuchClientException> orElseThrow(() -> new NoSuchClientException("Client id not found."));
clientDetailsEntity.setClientSecret(passwordEncoder.encode(secret));
clientDetailsRepository.save(clientDetailsEntity);
}
示例10: loadClientByClientId
import org.springframework.security.oauth2.provider.NoSuchClientException; //导入依赖的package包/类
@Override
public ClientDetails loadClientByClientId(String clientId) throws ClientRegistrationException {
ClientDetails details = clientDetails.get(clientId);
if (details == null) {
throw new NoSuchClientException("No client with requested id: " + clientId);
}
return details;
}
示例11: loadClientByClientId
import org.springframework.security.oauth2.provider.NoSuchClientException; //导入依赖的package包/类
@Override
public org.springframework.security.oauth2.provider.ClientDetails loadClientByClientId(String clientId) throws ClientRegistrationException {
try {
Client client = clientService.findByDomainAndClientId(domain.getId(), clientId);
if (client != null && client.isEnabled()) {
return new DelegateClientDetails(client);
}
} catch (ClientNotFoundException ignored) {
}
throw new NoSuchClientException("No client with requested id: " + clientId);
}
开发者ID:gravitee-io,项目名称:graviteeio-access-management,代码行数:14,代码来源:DomainBasedClientDetailsService.java
示例12: deactivate
import org.springframework.security.oauth2.provider.NoSuchClientException; //导入依赖的package包/类
@Override
public Plugin deactivate(Plugin plugin) {
try {
clientRegistrationService.removeClientDetails(plugin.getIdentifier());
} catch (NoSuchClientException exception) {
// ignore, remove silently
}
return plugin;
}
示例13: updateClientSecret
import org.springframework.security.oauth2.provider.NoSuchClientException; //导入依赖的package包/类
@Override
public void updateClientSecret(String clientId, String secret) throws NoSuchClientException {
final boolean result = mongoClientDetailsRepository.updateClientSecret(clientId, passwordEncoder.encode(secret));
if (!result) {
throw new NoSuchClientException("No such client id");
}
}
示例14: removeClientDetails
import org.springframework.security.oauth2.provider.NoSuchClientException; //导入依赖的package包/类
@Override
public void removeClientDetails(String clientId) throws NoSuchClientException {
final boolean result = mongoClientDetailsRepository.deleteByClientId(clientId);
if (!result) {
throw new NoSuchClientException("No such client id");
}
}
示例15: loadClientByClientId
import org.springframework.security.oauth2.provider.NoSuchClientException; //导入依赖的package包/类
@Override
public ClientDetails loadClientByClientId(final String clientId) {
ClientEntity client = clientRepository.findById(clientId);
if (client == null) {
throw new NoSuchClientException(String.format(
"OsiamClientDetailsService failed to load client with id %s: no client found",
clientId
));
}
return client;
}