當前位置: 首頁>>代碼示例>>Java>>正文


Java ClientDetails.getClientId方法代碼示例

本文整理匯總了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;
}
 
開發者ID:OwnYourData,項目名稱:oyd-pia,代碼行數:25,代碼來源:InMemoryProcessRepository.java

示例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);
}
 
開發者ID:cloudade,項目名稱:authorization-server-with-mongodb,代碼行數:17,代碼來源:MongoClientDetailsService.java

示例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");
	}
}
 
開發者ID:cloudade,項目名稱:authorization-server-with-mongodb,代碼行數:20,代碼來源:MongoClientDetailsService.java

示例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());
    }
}
 
開發者ID:cedac-software,項目名稱:spring-security-mongodb,代碼行數:10,代碼來源:MongoClientDetailsService.java

示例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());
    }
}
 
開發者ID:cedac-software,項目名稱:spring-security-mongodb,代碼行數:11,代碼來源:MongoClientDetailsService.java

示例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;
}
 
開發者ID:cedac-software,項目名稱:spring-security-mongodb,代碼行數:9,代碼來源:MongoClientDetailsService.java

示例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);
}
 
開發者ID:gdong42,項目名稱:spring-auth-example,代碼行數:43,代碼來源:CustomResourceOwnerPasswordTokenGranter.java


注:本文中的org.springframework.security.oauth2.provider.ClientDetails.getClientId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。