本文整理匯總了Java中org.springframework.security.oauth2.provider.ClientDetails.getClientId方法的典型用法代碼示例。如果您正苦於以下問題:Java ClientDetails.getClientId方法的具體用法?Java ClientDetails.getClientId怎麽用?Java ClientDetails.getClientId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.security.oauth2.provider.ClientDetails
的用法示例。
在下文中一共展示了ClientDetails.getClientId方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: create
import org.springframework.security.oauth2.provider.ClientDetails; //導入方法依賴的package包/類
@Override
public PluginProcess create(StandalonePlugin plugin) throws IOException {
ClientDetails clientDetails = clientDetailsService.loadClientByClientId(plugin.getIdentifier());
String clientId = clientDetails.getClientId();
String clientSecret = clientDetails.getClientSecret();
File log = new File(FilenameUtils.concat(plugin.getPath(), plugin.getIdentifier() + ".log"));
Environment env = applicationContext.getEnvironment();
PluginProcess process = new PluginProcessBuilder(plugin.getStartCommand().split(" "))
.directory(new File(plugin.getPath()))
.withNodeProductionEnvironment()
.clientIdentifier(clientId)
.clientSecret(clientSecret)
.piaInetAddress(InetAddress.getLocalHost())
.piaPort(env.getProperty("server.port"))
.anyPluginPort()
.redirectError(log)
.redirectOutput(log).start();
processes.put(plugin,process);
return process;
}
示例2: addClientDetails
import org.springframework.security.oauth2.provider.ClientDetails; //導入方法依賴的package包/類
@Override
public void addClientDetails(final ClientDetails clientDetails) throws ClientAlreadyExistsException {
final MongoClientDetails mongoClientDetails = new MongoClientDetails(clientDetails.getClientId(),
passwordEncoder.encode(clientDetails.getClientSecret()),
clientDetails.getScope(),
clientDetails.getResourceIds(),
clientDetails.getAuthorizedGrantTypes(),
clientDetails.getRegisteredRedirectUri(),
newArrayList(clientDetails.getAuthorities()),
clientDetails.getAccessTokenValiditySeconds(),
clientDetails.getRefreshTokenValiditySeconds(),
clientDetails.getAdditionalInformation(),
null);
mongoClientDetailsRepository.save(mongoClientDetails);
}
示例3: updateClientDetails
import org.springframework.security.oauth2.provider.ClientDetails; //導入方法依賴的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: addClientDetails
import org.springframework.security.oauth2.provider.ClientDetails; //導入方法依賴的package包/類
public void addClientDetails(ClientDetails clientDetails) throws ClientAlreadyExistsException {
DBObject query = new BasicDBObject(clientIdFieldName, clientDetails.getClientId());
if (getClientDetailsCollection().count(query) == 0) {
DBObject entry = toDBObject(clientDetails);
getClientDetailsCollection().insert(entry, writeConcern);
} else {
throw new ClientAlreadyExistsException("Client already exists: " + clientDetails.getClientId());
}
}
示例5: updateClientDetails
import org.springframework.security.oauth2.provider.ClientDetails; //導入方法依賴的package包/類
public void updateClientDetails(ClientDetails clientDetails) throws NoSuchClientException {
DBObject query = new BasicDBObject(clientIdFieldName, clientDetails.getClientId());
DBObject entry = getClientDetailsCollection().findOne(query);
if (entry != null) {
updateDBObject(entry, clientDetails);
getClientDetailsCollection().save(entry, writeConcern);
} else {
throw new NoSuchClientException("No client found with id = " + clientDetails.getClientId());
}
}
示例6: toDBObject
import org.springframework.security.oauth2.provider.ClientDetails; //導入方法依賴的package包/類
private DBObject toDBObject(ClientDetails clientDetails) {
BasicDBObject dbo = new BasicDBObject(clientIdFieldName, clientDetails.getClientId());
if (clientDetails.isSecretRequired()) {
dbo.put(clientSecretFieldName, passwordEncoder.encode(clientDetails.getClientSecret()));
}
updateDBObject(dbo, clientDetails);
return dbo;
}
示例7: getOAuth2Authentication
import org.springframework.security.oauth2.provider.ClientDetails; //導入方法依賴的package包/類
@Override
protected OAuth2Authentication getOAuth2Authentication(ClientDetails client,
TokenRequest tokenRequest) {
Map<String, String> parameters = new LinkedHashMap<String, String>(
tokenRequest.getRequestParameters());
String username = parameters.get("username");
String password = parameters.get("password");
String clientId = client.getClientId();
// Protect from downstream leaks of password
parameters.remove("password");
Authentication userAuth;
if ("foo_app".equalsIgnoreCase(clientId)) {
userAuth = new FooUsernamePasswordAuthenticationToken(username,
password);
} else if ("bar_app".equalsIgnoreCase(clientId)) {
userAuth = new BarUsernamePasswordAuthenticationToken(username,
password);
} else {
throw new InvalidGrantException("Unknown client: " + clientId);
}
((AbstractAuthenticationToken) userAuth).setDetails(parameters);
try {
userAuth = authenticationManager.authenticate(userAuth);
} catch (AccountStatusException ase) {
//covers expired, locked, disabled cases (mentioned in section 5.2, draft 31)
throw new InvalidGrantException(ase.getMessage());
} catch (BadCredentialsException e) {
// If the username/password are wrong the spec says we should send 400/invalid grant
throw new InvalidGrantException(e.getMessage());
}
if (userAuth == null || !userAuth.isAuthenticated()) {
throw new InvalidGrantException(
"Could not authenticate user: " + username);
}
OAuth2Request storedOAuth2Request = getRequestFactory()
.createOAuth2Request(client, tokenRequest);
return new OAuth2Authentication(storedOAuth2Request, userAuth);
}