com.stormpath.sdk.application.Application.getAccount()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(79)

本文整理了Java中com.stormpath.sdk.application.Application.getAccount()方法的一些代码示例,展示了Application.getAccount()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Application.getAccount()方法的具体详情如下:
包路径:com.stormpath.sdk.application.Application
类名称:Application
方法名:getAccount

Application.getAccount介绍

[英]Retrieves a Provider-based Account. The account must exist in one of the Provider-based com.stormpath.sdk.directory.Directoryassigned to the Application as an #getAccountStoreMappings(), the Directory must also be Enabled. If not in an assigned account store, the retrieval attempt will fail. Example Consider the following example:

ProviderAccountRequest request = Providers.GOOGLE.account() 
.setCode("4/mV9k80PpUB7XK_2RvOqOkNrI7I8C.krFm0WYFM_sY3pEBd8D1tNHT8u6jiwI") 
.build(); 
ProviderAccountResult result = application.getAccount(request); 
Account account = result.getAccount();

[中]检索基于提供程序的帐户。该帐户必须存在于一个基于提供程序的com中。暴风雨之路。sdk。目录目录作为#getAccountStoreMappings()分配给应用程序,还必须启用该目录。如果不在分配的帐户存储中,检索尝试将失败。例如,考虑下面的例子:

ProviderAccountRequest request = Providers.GOOGLE.account() 
.setCode("4/mV9k80PpUB7XK_2RvOqOkNrI7I8C.krFm0WYFM_sY3pEBd8D1tNHT8u6jiwI") 
.build(); 
ProviderAccountResult result = application.getAccount(request); 
Account account = result.getAccount();

代码示例

代码示例来源:origin: stackoverflow.com

Client client = Clients.builder().build();

Application application = client.getResource(applicationHref, Application.class);

ProviderAccountRequest request = Providers.GOOGLE.account()
    .setCode(code) //where code is the value we obtained in step 8
    .build();

ProviderAccountResult result = application.getAccount(request);
System.out.println("Account Email: " + result.getAccount().getEmail());
ProviderData providerData = result.getAccount().getProviderData();
System.out.println("Access Token: " + ((GoogleProviderData)providerData).getAccessToken());

代码示例来源:origin: com.stormpath.spring/stormpath-spring-security-webmvc

ProviderAccountResult result = application.getAccount(accountRequest);
Account account = result.getAccount();
return getAuthenticationManager().authenticate(new ProviderAuthenticationToken(account));

代码示例来源:origin: stormpath/stormpath-sdk-java

ProviderAccountResult result = application.getAccount(accountRequest);
Account account = result.getAccount();
return getAuthenticationManager().authenticate(new ProviderAuthenticationToken(account));

代码示例来源:origin: stormpath/stormpath-sdk-java

return;
ProviderAccountResult result = application.getAccount(providerAccountRequest);
Account account = result.getAccount();
if (account != null) {

代码示例来源:origin: com.stormpath.spring/stormpath-spring-security-webmvc

return;
ProviderAccountResult result = application.getAccount(providerAccountRequest);
Account account = result.getAccount();
if (account != null) {

代码示例来源:origin: stormpath/stormpath-sdk-java

ProviderAccountResult result = getApplication(request).getAccount(accountRequest);
Account account = result.getAccount();
if (account.getStatus().equals(AccountStatus.ENABLED)) {

代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-servlet

ProviderAccountResult result = getApplication(request).getAccount(accountRequest);
Account account = result.getAccount();
if (account.getStatus().equals(AccountStatus.ENABLED)) {

代码示例来源:origin: stormpath/stormpath-sdk-java

@Override
protected ViewModel doGet(HttpServletRequest request, HttpServletResponse response) throws Exception {
  ProviderAccountRequest providerRequest = getAccountProviderRequest(request);
  ProviderAccountResult result = getApplication(request).getAccount(providerRequest);
  // 751: Check if account is unverified and redirect to verifyUri if true
  Account account = result.getAccount();
  if (account.getStatus().equals(AccountStatus.UNVERIFIED)) {
    Config config = (Config) request.getServletContext().getAttribute(Config.class.getName());
    String loginUri = config.getLoginConfig().getUri();
    return new DefaultViewModel(loginUri + "?status=unverified").setRedirect(true);
  }
  AuthenticationResult authcResult = new TransientAuthenticationResult(result.getAccount());
  authenticationResultSaver.set(request, response, authcResult);
  eventPublisher.publish(new DefaultSuccessfulAuthenticationRequestEvent(request, response, null, authcResult));
  String redirectUri = getRedirectUri(request);
  return new DefaultViewModel(redirectUri).setRedirect(true);
}

代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-servlet

@Override
protected ViewModel doGet(HttpServletRequest request, HttpServletResponse response) throws Exception {
  ProviderAccountRequest providerRequest = getAccountProviderRequest(request);
  ProviderAccountResult result = getApplication(request).getAccount(providerRequest);
  // 751: Check if account is unverified and redirect to verifyUri if true
  Account account = result.getAccount();
  if (account.getStatus().equals(AccountStatus.UNVERIFIED)) {
    Config config = (Config) request.getServletContext().getAttribute(Config.class.getName());
    String loginUri = config.getLoginConfig().getUri();
    return new DefaultViewModel(loginUri + "?status=unverified").setRedirect(true);
  }
  AuthenticationResult authcResult = new TransientAuthenticationResult(result.getAccount());
  authenticationResultSaver.set(request, response, authcResult);
  eventPublisher.publish(new DefaultSuccessfulAuthenticationRequestEvent(request, response, null, authcResult));
  String redirectUri = getRedirectUri(request);
  return new DefaultViewModel(redirectUri).setRedirect(true);
}

代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-servlet

@Override
protected ViewModel doGet(HttpServletRequest request, HttpServletResponse response) throws Exception {
  String errorDescription = ServletUtils.getCleanParam(request, "error_description");
  if (errorDescription != null) {
    return new DefaultViewModel( getNextUri()+ "?error="+errorDescription).setRedirect(true);
  } else {
    final ProviderAccountRequest providerRequest = getAccountProviderRequest(request);
    final DefaultOktaProviderAccountResult result = (DefaultOktaProviderAccountResult) getApplication(request).getAccount(providerRequest);
    // 751: Check if account is unverified and redirect to verifyUri if true
    final Account account = result.getAccount();
    if (account.getStatus().equals(AccountStatus.UNVERIFIED)) {
      Config config = (Config) request.getServletContext().getAttribute(Config.class.getName());
      String loginUri = config.getLoginConfig().getUri();
      return new DefaultViewModel(loginUri + "?status=unverified").setRedirect(true);
    }
    DefaultOktaAccessTokenResult authcResult = new DefaultOktaAccessTokenResult(result.getTokenResponse(), account);
    authenticationResultSaver.set(request, response, authcResult);
    eventPublisher.publish(new DefaultSuccessfulAuthenticationRequestEvent(request, response, null, authcResult));
    String redirectUri = getRedirectUri(request);
    return new DefaultViewModel(redirectUri).setRedirect(true);
  }
}

代码示例来源:origin: stormpath/stormpath-sdk-java

@Override
protected ViewModel doGet(HttpServletRequest request, HttpServletResponse response) throws Exception {
  String errorDescription = ServletUtils.getCleanParam(request, "error_description");
  if (errorDescription != null) {
    return new DefaultViewModel( getNextUri()+ "?error="+errorDescription).setRedirect(true);
  } else {
    final ProviderAccountRequest providerRequest = getAccountProviderRequest(request);
    final DefaultOktaProviderAccountResult result = (DefaultOktaProviderAccountResult) getApplication(request).getAccount(providerRequest);
    // 751: Check if account is unverified and redirect to verifyUri if true
    final Account account = result.getAccount();
    if (account.getStatus().equals(AccountStatus.UNVERIFIED)) {
      Config config = (Config) request.getServletContext().getAttribute(Config.class.getName());
      String loginUri = config.getLoginConfig().getUri();
      return new DefaultViewModel(loginUri + "?status=unverified").setRedirect(true);
    }
    DefaultOktaAccessTokenResult authcResult = new DefaultOktaAccessTokenResult(result.getTokenResponse(), account);
    authenticationResultSaver.set(request, response, authcResult);
    eventPublisher.publish(new DefaultSuccessfulAuthenticationRequestEvent(request, response, null, authcResult));
    String redirectUri = getRedirectUri(request);
    return new DefaultViewModel(redirectUri).setRedirect(true);
  }
}

相关文章