本文整理汇总了Java中com.nimbusds.oauth2.sdk.ResponseMode类的典型用法代码示例。如果您正苦于以下问题:Java ResponseMode类的具体用法?Java ResponseMode怎么用?Java ResponseMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResponseMode类属于com.nimbusds.oauth2.sdk包,在下文中一共展示了ResponseMode类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleAuthorizationCodeFlow
import com.nimbusds.oauth2.sdk.ResponseMode; //导入依赖的package包/类
private AuthenticationSuccessResponse handleAuthorizationCodeFlow(AuthenticationRequest authRequest,
OIDCClientInformation client, HttpServletRequest request, Subject subject) throws GeneralException {
ResponseMode responseMode = authRequest.impliedResponseMode();
ClientID clientId = authRequest.getClientID();
URI redirectUri = authRequest.getRedirectionURI();
Scope requestedScope = authRequest.getScope();
CodeChallenge codeChallenge = authRequest.getCodeChallenge();
CodeChallengeMethod codeChallengeMethod = authRequest.getCodeChallengeMethod();
Nonce nonce = authRequest.getNonce();
Instant authenticationTime = Instant.ofEpochMilli(request.getSession().getCreationTime());
ACR acr = this.acr;
AMR amr = AMR.PWD;
SessionID sessionId = new SessionID(request.getSession().getId());
State sessionState = this.sessionManagementEnabled ? State.parse(sessionId.getValue()) : null;
Scope scope = this.scopeResolver.resolve(subject, requestedScope, client.getOIDCMetadata());
AuthorizationCodeContext context = new AuthorizationCodeContext(subject, clientId, redirectUri, scope,
authenticationTime, acr, amr, sessionId, codeChallenge, codeChallengeMethod, nonce);
AuthorizationCode code = this.authorizationCodeService.create(context);
return new AuthenticationSuccessResponse(redirectUri, code, null, null, authRequest.getState(), sessionState,
responseMode);
}
示例2: handleImplicitFlow
import com.nimbusds.oauth2.sdk.ResponseMode; //导入依赖的package包/类
private AuthenticationSuccessResponse handleImplicitFlow(AuthenticationRequest authRequest,
OIDCClientInformation client, HttpServletRequest request, Subject subject) throws GeneralException {
ResponseType responseType = authRequest.getResponseType();
ResponseMode responseMode = authRequest.impliedResponseMode();
URI redirectUri = authRequest.getRedirectionURI();
Scope requestedScope = authRequest.getScope();
State state = authRequest.getState();
Nonce nonce = authRequest.getNonce();
Instant authenticationTime = Instant.ofEpochMilli(request.getSession().getCreationTime());
ACR acr = this.acr;
AMR amr = AMR.PWD;
SessionID sessionId = new SessionID(request.getSession().getId());
State sessionState = this.sessionManagementEnabled ? State.parse(sessionId.getValue()) : null;
Scope scope = this.scopeResolver.resolve(subject, requestedScope, client.getOIDCMetadata());
AccessToken accessToken = null;
if (responseType.contains(ResponseType.Value.TOKEN)) {
AccessTokenRequest accessTokenRequest = new AccessTokenRequest(subject, client, scope);
accessToken = this.tokenService.createAccessToken(accessTokenRequest);
}
IdTokenRequest idTokenRequest = new IdTokenRequest(subject, client, scope, authenticationTime, acr, amr,
sessionId, nonce, accessToken, null);
JWT idToken = this.tokenService.createIdToken(idTokenRequest);
return new AuthenticationSuccessResponse(redirectUri, null, idToken, accessToken, state, sessionState,
responseMode);
}
示例3: handleHybridFlow
import com.nimbusds.oauth2.sdk.ResponseMode; //导入依赖的package包/类
private AuthenticationSuccessResponse handleHybridFlow(AuthenticationRequest authRequest,
OIDCClientInformation client, HttpServletRequest request, Subject subject) throws GeneralException {
ResponseType responseType = authRequest.getResponseType();
ResponseMode responseMode = authRequest.impliedResponseMode();
ClientID clientId = authRequest.getClientID();
URI redirectUri = authRequest.getRedirectionURI();
Scope requestedScope = authRequest.getScope();
State state = authRequest.getState();
CodeChallenge codeChallenge = authRequest.getCodeChallenge();
CodeChallengeMethod codeChallengeMethod = authRequest.getCodeChallengeMethod();
Nonce nonce = authRequest.getNonce();
Instant authenticationTime = Instant.ofEpochMilli(request.getSession().getCreationTime());
ACR acr = this.acr;
AMR amr = AMR.PWD;
SessionID sessionId = new SessionID(request.getSession().getId());
State sessionState = this.sessionManagementEnabled ? State.parse(sessionId.getValue()) : null;
Scope scope = this.scopeResolver.resolve(subject, requestedScope, client.getOIDCMetadata());
AuthorizationCodeContext context = new AuthorizationCodeContext(subject, clientId, redirectUri, scope,
authenticationTime, acr, amr, sessionId, codeChallenge, codeChallengeMethod, nonce);
AuthorizationCode code = this.authorizationCodeService.create(context);
AccessToken accessToken = null;
if (responseType.contains(ResponseType.Value.TOKEN)) {
AccessTokenRequest accessTokenRequest = new AccessTokenRequest(subject, client, scope);
accessToken = this.tokenService.createAccessToken(accessTokenRequest);
}
JWT idToken = null;
if (responseType.contains(OIDCResponseTypeValue.ID_TOKEN)) {
IdTokenRequest idTokenRequest = new IdTokenRequest(subject, client, scope, authenticationTime, acr, amr,
sessionId, nonce, accessToken, code);
idToken = this.tokenService.createIdToken(idTokenRequest);
}
return new AuthenticationSuccessResponse(redirectUri, code, idToken, accessToken, state, sessionState,
responseMode);
}
示例4: getDefaultOPMetadata
import com.nimbusds.oauth2.sdk.ResponseMode; //导入依赖的package包/类
protected OIDCProviderMetadata getDefaultOPMetadata() throws ParseException {
Issuer issuer = getMetadataIssuer();
List<SubjectType> subjectTypes = Arrays.asList(SubjectType.PUBLIC);
URI jwksUri = UriBuilder.fromUri(baseUri).path(JWKS_PATH).build();
OIDCProviderMetadata md = new OIDCProviderMetadata(issuer, subjectTypes, jwksUri);
md.applyDefaults();
// endpoints
URI authzEndpt = getMetadataAuthorizationEndpoint();
URI tokenEndpt = getMetadataTokenEndpoint();
URI userInfoEndpt = getMetadataUserinfoEndpoint();
URI registrationEndpt = getMetadataRegistrationEndpoint();
md.setAuthorizationEndpointURI(authzEndpt);
md.setTokenEndpointURI(tokenEndpt);
md.setUserInfoEndpointURI(userInfoEndpt);
md.setRegistrationEndpointURI(registrationEndpt);
// , ResponseType.parse("id_token"), ResponseType.parse("token id_token"));
Scope scopes = new Scope("openid");
List<ResponseType> responseTypes = Arrays.asList(ResponseType.parse("code"), ResponseType.parse("id_token"),
ResponseType.parse("token id_token"));
List<ResponseMode> responseModes = Arrays.asList(ResponseMode.QUERY, ResponseMode.FRAGMENT, ResponseMode.FORM_POST);
List<GrantType> grantTypes = Arrays.asList(GrantType.AUTHORIZATION_CODE, GrantType.IMPLICIT);
md.setScopes(scopes);
md.setResponseTypes(responseTypes);
md.setResponseModes(responseModes);
md.setGrantTypes(grantTypes);
// algorithms
List<JWSAlgorithm> jwsAlgs = Arrays.asList(JWSAlgorithm.RS256, JWSAlgorithm.parse("none"));
md.setIDTokenJWSAlgs(jwsAlgs);
List<ClientAuthenticationMethod> authMethods = Arrays.asList(ClientAuthenticationMethod.CLIENT_SECRET_BASIC);
md.setTokenEndpointAuthMethods(authMethods);
List<Display> displays = Arrays.asList(Display.PAGE);
md.setDisplays(displays);
return md;
}
示例5: buildAuthorizationURL
import com.nimbusds.oauth2.sdk.ResponseMode; //导入依赖的package包/类
private String buildAuthorizationURL(HttpServerExchange exchange) {
try {
ClientID clientId = new ClientID(oidcProvider.getClientId());
ResponseType responseType = new ResponseType(oidcProvider.getResponseType());
ResponseMode responseMode = ResponseMode.FORM_POST;
Prompt prompt = new Prompt(Prompt.Type.LOGIN);
Display display = Display.PAGE;
Scope scope = Scope.parse(oidcProvider.getScope());
String redirectURL = RedirectBuilder.redirect(exchange, redirectPath, false);
URI redirectURI = new URI(redirectURL);
String returnURL = null;
if (!exchange.getRequestPath().equals(redirectPath)) {
returnURL = RedirectBuilder.redirect(exchange, exchange.getRelativePath());
} else {
returnURL = RedirectBuilder.redirect(exchange, "/", false);
}
String stateValue = persistState(returnURL, exchange);
State state = stateValue != null ? new State(stateValue) : null;
Nonce nonce = new Nonce();
if (oidcProvider.isCheckNonce()) {
getSession(exchange).setAttribute(NONCE_KEY, nonce.getValue());
}
AuthenticationRequest authRequest = new AuthenticationRequest(oidcProvider.getAuthURI(), responseType, responseMode, scope, clientId, redirectURI, state, nonce, display, prompt, -1, null, null, null, null, null, oidcProvider.getClaims(), null, null, null, null);
return authRequest.toURI().toString();
} catch (Exception e) {
LOG.log(Level.SEVERE, "", e);
return null;
}
}
示例6: responseModes
import com.nimbusds.oauth2.sdk.ResponseMode; //导入依赖的package包/类
private List<ResponseMode> responseModes() {
return Arrays.asList(ResponseMode.QUERY, ResponseMode.FRAGMENT, ResponseMode.FORM_POST);
}