本文整理汇总了Java中org.springframework.security.oauth2.common.AuthenticationScheme类的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationScheme类的具体用法?Java AuthenticationScheme怎么用?Java AuthenticationScheme使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuthenticationScheme类属于org.springframework.security.oauth2.common包,在下文中一共展示了AuthenticationScheme类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: authorizationCode
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
@Bean
public AuthorizationCodeResourceDetails authorizationCode() {
AuthorizationCodeResourceDetails resourceDetails = new AuthorizationCodeResourceDetails();
resourceDetails.setId("oauth2server");
resourceDetails.setTokenName("oauth_token");
resourceDetails.setClientId("clientapp");
resourceDetails.setClientSecret("123456");
resourceDetails.setAccessTokenUri("http://localhost:8080/oauth/token");
resourceDetails.setUserAuthorizationUri("http://localhost:8080/oauth/authorize");
resourceDetails.setScope(Arrays.asList("read_profile"));
resourceDetails.setPreEstablishedRedirectUri(("http://localhost:9000/callback"));
resourceDetails.setUseCurrentUri(false);
resourceDetails.setClientAuthenticationScheme(AuthenticationScheme.header);
return resourceDetails;
}
开发者ID:PacktPublishing,项目名称:OAuth-2.0-Cookbook,代码行数:18,代码来源:ClientConfiguration.java
示例2: passwordResourceDetails
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
@Bean
public OAuth2ProtectedResourceDetails passwordResourceDetails() {
//@formatter:off
ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails();
details.setId("oauth2server");
details.setTokenName("oauth_token");
details.setClientId("clientadmin");
details.setClientSecret("123");
details.setAccessTokenUri("http://localhost:8080/oauth/token");
details.setScope(Arrays.asList("admin"));
details.setClientAuthenticationScheme(AuthenticationScheme.header);
//@formatter:on
return details;
}
开发者ID:PacktPublishing,项目名称:OAuth-2.0-Cookbook,代码行数:18,代码来源:ClientConfiguration.java
示例3: passwordResourceDetails
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
@Bean
public OAuth2ProtectedResourceDetails passwordResourceDetails() {
//@formatter:off
ResourceOwnerPasswordResourceDetails resourceDetails = new ResourceOwnerPasswordResourceDetails();
resourceDetails.setId("oauth2server");
resourceDetails.setTokenName("oauth_token");
resourceDetails.setClientId("clientapp");
resourceDetails.setClientSecret("123456");
resourceDetails.setAccessTokenUri("http://localhost:8080/oauth/token");
resourceDetails.setScope(Arrays.asList("read_profile"));
resourceDetails.setClientAuthenticationScheme(AuthenticationScheme.header);
//@formatter:on
return resourceDetails;
}
开发者ID:PacktPublishing,项目名称:OAuth-2.0-Cookbook,代码行数:18,代码来源:ClientConfiguration.java
示例4: implicitResourceDetails
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
@Bean
public OAuth2ProtectedResourceDetails implicitResourceDetails() {
ImplicitResourceDetails resourceDetails = new ImplicitResourceDetails();
//@formatter:off
resourceDetails.setId("oauth2server");
resourceDetails.setTokenName("oauth_token");
resourceDetails.setClientId("clientapp");
resourceDetails.setUserAuthorizationUri("http://localhost:8080/oauth/authorize");
resourceDetails.setScope(Arrays.asList("read_profile"));
resourceDetails.setPreEstablishedRedirectUri("http://localhost:9000/callback");
resourceDetails.setUseCurrentUri(false);
resourceDetails.setClientAuthenticationScheme(AuthenticationScheme.query);
//@formatter:on
return resourceDetails;
}
开发者ID:PacktPublishing,项目名称:OAuth-2.0-Cookbook,代码行数:18,代码来源:ClientConfiguration.java
示例5: implicitResourceRestTemplate
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
/**
* 该方式没有实验成功,设置为 Deprecated!
* <p>
* 演示 grant_type=implicit 时,获取资源的方法
*
* @param client_id
* @param client_secret 取决于 AuthorizationServer 设置,如果 client 设置了secret,则此项参数为必需,否则可以没有
* @param authorization_uri
* @param access_token_uri
* @param scope
* @return
*/
@Deprecated
public OAuth2RestOperations implicitResourceRestTemplate(String client_id, String client_secret, String authorization_uri, String access_token_uri, String... scope) {
// 防止 url 写错
if (!authorization_uri.contains("authorize"))
throw new RuntimeException("uri is wrong : authorization_uri" + authorization_uri);
ImplicitResourceDetails details = new ImplicitResourceDetails();
details.setId("2");
details.setClientId(client_id);
if (client_secret != null && !client_secret.isEmpty())
details.setClientSecret(client_secret);
details.setAccessTokenUri(authorization_uri);
details.setClientAuthenticationScheme(AuthenticationScheme.header);
details.setUseCurrentUri(true);
details.setScope(Arrays.asList(scope));
// return restTemplate;
return new OAuth2RestTemplate(details, oAuth2ClientContext);
}
开发者ID:h819,项目名称:spring-boot,代码行数:32,代码来源:Oauth2ClientRestTemplate.java
示例6: connect
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
private UaaConnection connect(String providerUser, String providerPassword) throws DriverConnectionException {
if (uaaUrl == null) {
throw new DriverConnectionException(this, "Uaa is not registered in the broker, this driver can't be used");
}
ClientCredentialsResourceDetails credentials = new ClientCredentialsResourceDetails();
credentials.setAccessTokenUri(uaaUrl + "/oauth/token");
credentials.setClientAuthenticationScheme(AuthenticationScheme.header);
credentials.setClientId(providerUser);
credentials.setClientSecret(providerPassword);
URL uaaHost = null;
try {
uaaHost = new URL(uaaUrl);
} catch (MalformedURLException e) {
throw new DriverConnectionException(this, e.getMessage(), e);
}
return UaaConnectionFactory.getConnection(uaaHost, credentials);
}
开发者ID:cloudfoundry-community,项目名称:oauth-register-broker,代码行数:21,代码来源:UaaDriver.java
示例7: createRequest
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
@Override
protected ClientHttpRequest createRequest(URI uri, HttpMethod method) throws IOException {
OAuth2AccessToken accessToken = getAccessToken();
AuthenticationScheme authenticationScheme = resource.getAuthenticationScheme();
if (AuthenticationScheme.query.equals(authenticationScheme)
|| AuthenticationScheme.form.equals(authenticationScheme)) {
uri = appendQueryParameter(uri, accessToken);
}
ClientHttpRequest req = super.createRequest(uri, method);
if (AuthenticationScheme.header.equals(authenticationScheme)) {
authenticator.authenticate(resource, getOAuth2ClientContext(), req);
}
return req;
}
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:20,代码来源:OAuth2RestTemplate.java
示例8: getResourceDetails
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
private OAuth2ProtectedResourceDetails getResourceDetails(String username, String password, String clientId, String clientSecret) {
ResourceOwnerPasswordResourceDetails resource = new ResourceOwnerPasswordResourceDetails();
resource.setUsername(username);
resource.setPassword(password);
resource.setClientId(clientId);
resource.setClientSecret(clientSecret);
resource.setId(clientId);
resource.setClientAuthenticationScheme(AuthenticationScheme.header);
resource.setAccessTokenUri(authorizationUrl + "/oauth/token");
return resource;
}
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:14,代码来源:OauthClient.java
示例9: resourceDetails
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
@Bean
public OAuth2ProtectedResourceDetails resourceDetails() {
AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails();
details.setClientId(properties.getClientId());
details.setClientSecret(properties.getClientSecret());
details.setUserAuthorizationUri(properties.getAppAuthorizationUri());
details.setAccessTokenUri(properties.getAppTokenUri());
details.setPreEstablishedRedirectUri(properties.getRedirectUri());
details.setScope(Arrays.asList("email", "public_profile"));
details.setClientAuthenticationScheme(AuthenticationScheme.query);
details.setUseCurrentUri(false);
return details;
}
开发者ID:PacktPublishing,项目名称:OAuth-2.0-Cookbook,代码行数:14,代码来源:FacebookConfiguration.java
示例10: authorizationCode
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
@Bean
public OAuth2ProtectedResourceDetails authorizationCode() {
AuthorizationCodeResourceDetails resourceDetails = new AuthorizationCodeResourceDetails();
//@formatter:off
resourceDetails.setId("oauth2server");
resourceDetails.setTokenName("oauth_token");
resourceDetails.setClientId("clientapp");
resourceDetails.setClientSecret("123456");
resourceDetails.setAccessTokenUri("http://localhost:8080/oauth/token");
resourceDetails.setUserAuthorizationUri("http://localhost:8080/oauth/authorize");
resourceDetails.setScope(Arrays.asList("read_profile"));
resourceDetails.setPreEstablishedRedirectUri(("http://localhost:9000/callback"));
resourceDetails.setUseCurrentUri(false);
resourceDetails.setClientAuthenticationScheme(AuthenticationScheme.header);
//@formatter:on
return resourceDetails;
}
开发者ID:PacktPublishing,项目名称:OAuth-2.0-Cookbook,代码行数:20,代码来源:ClientConfiguration.java
示例11: resourceDetails
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
@Bean("practiceClientCredentialsResourceDetails")
public ClientCredentialsResourceDetails resourceDetails() {
ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails();
details.setId(oauth2ClientProperties.getId());
details.setAccessTokenUri(oauth2ClientProperties.getAccessTokenUrl());
details.setClientId(oauth2ClientProperties.getClientId());
details.setClientSecret(oauth2ClientProperties.getClientSecret());
details.setAuthenticationScheme(AuthenticationScheme.valueOf(oauth2ClientProperties.getClientAuthenticationScheme()));
return details;
}
开发者ID:sdcuike,项目名称:spring-boot-oauth2-demo,代码行数:11,代码来源:Oauth2ClientConfig.java
示例12: getResource
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
@Override
public OAuth2ProtectedResourceDetails getResource() {
AuthorizationCodeResourceDetails resource = (AuthorizationCodeResourceDetails) super.getResource();
resource.setAuthenticationScheme(AuthenticationScheme.none);
return resource;
}
开发者ID:openmhealth,项目名称:shimmer,代码行数:8,代码来源:IHealthShim.java
示例13: authenticateTokenRequest
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
public void authenticateTokenRequest(OAuth2ProtectedResourceDetails resource, MultiValueMap<String, String> form,
HttpHeaders headers) {
if (resource.isAuthenticationRequired()) {
AuthenticationScheme scheme = AuthenticationScheme.header;
if (resource.getClientAuthenticationScheme() != null) {
scheme = resource.getClientAuthenticationScheme();
}
try {
String clientSecret = resource.getClientSecret();
clientSecret = clientSecret == null ? "" : clientSecret;
switch (scheme) {
case header:
form.remove("client_secret");
headers.add(
"Authorization",
String.format(
"Basic %s",
new String(Base64.encode(String.format("%s:%s", resource.getClientId(),
clientSecret).getBytes("UTF-8")), "UTF-8")));
break;
case form:
case query:
form.set("client_id", resource.getClientId());
if (StringUtils.hasText(clientSecret)) {
form.set("client_secret", clientSecret);
}
break;
default:
throw new IllegalStateException(
"Default authentication handler doesn't know how to handle scheme: " + scheme);
}
}
catch (UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
}
}
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:39,代码来源:DefaultClientAuthenticationHandler.java
示例14: facebook
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
@Bean
public OAuth2ProtectedResourceDetails facebook() {
AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails();
details.setId("facebook");
details.setClientId("233668646673605");
details.setClientSecret("33b17e044ee6a4fa383f46ec6e28ea1d");
details.setAccessTokenUri("https://graph.facebook.com/oauth/access_token");
details.setUserAuthorizationUri("https://www.facebook.com/dialog/oauth");
details.setTokenName("oauth_token");
details.setAuthenticationScheme(AuthenticationScheme.query);
details.setClientAuthenticationScheme(AuthenticationScheme.form);
return details;
}
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:14,代码来源:WebMvcConfig.java
示例15: testInvalidCredentialsWithFormAuthentication
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
@Test
@OAuth2ContextConfiguration(resource = InvalidClientCredentials.class, initialize = false)
public void testInvalidCredentialsWithFormAuthentication() throws Exception {
resource.setClientAuthenticationScheme(AuthenticationScheme.form);
context.setAccessTokenProvider(new ClientCredentialsAccessTokenProvider() {
@Override
protected ResponseErrorHandler getResponseErrorHandler() {
return new DefaultResponseErrorHandler() {
public void handleError(ClientHttpResponse response) throws IOException {
responseHeaders = response.getHeaders();
responseStatus = response.getStatusCode();
}
};
}
});
try {
context.getAccessToken();
fail("Expected ResourceAccessException");
}
catch (Exception e) {
// ignore
}
// System.err.println(responseHeaders);
String header = responseHeaders.getFirst("WWW-Authenticate");
assertTrue("Wrong header: " + header, header.contains("Form realm"));
assertEquals(HttpStatus.UNAUTHORIZED, responseStatus);
}
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:28,代码来源:ClientCredentialsProviderTests.java
示例16: isAuthenticationRequired
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
public boolean isAuthenticationRequired() {
return StringUtils.hasText(clientId) && clientAuthenticationScheme != AuthenticationScheme.none;
}
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:4,代码来源:BaseOAuth2ProtectedResourceDetails.java
示例17: getClientAuthenticationScheme
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
public AuthenticationScheme getClientAuthenticationScheme() {
return clientAuthenticationScheme;
}
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:4,代码来源:BaseOAuth2ProtectedResourceDetails.java
示例18: setClientAuthenticationScheme
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
public void setClientAuthenticationScheme(AuthenticationScheme clientAuthenticationScheme) {
this.clientAuthenticationScheme = clientAuthenticationScheme;
}
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:4,代码来源:BaseOAuth2ProtectedResourceDetails.java
示例19: getAuthenticationScheme
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
public AuthenticationScheme getAuthenticationScheme() {
return authorizationScheme;
}
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:4,代码来源:BaseOAuth2ProtectedResourceDetails.java
示例20: setAuthenticationScheme
import org.springframework.security.oauth2.common.AuthenticationScheme; //导入依赖的package包/类
public void setAuthenticationScheme(AuthenticationScheme authorizationScheme) {
this.authorizationScheme = authorizationScheme;
}
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:4,代码来源:BaseOAuth2ProtectedResourceDetails.java
注:本文中的org.springframework.security.oauth2.common.AuthenticationScheme类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论