• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ErrorObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.nimbusds.oauth2.sdk.ErrorObject的典型用法代码示例。如果您正苦于以下问题:Java ErrorObject类的具体用法?Java ErrorObject怎么用?Java ErrorObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ErrorObject类属于com.nimbusds.oauth2.sdk包,在下文中一共展示了ErrorObject类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testResponseEncoding

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
@Test
public void testResponseEncoding() throws Exception {

    AuthenticationErrorResponse resp = new AuthenticationErrorResponse(new URI("https://example.org"),
            new ErrorObject("code", "desc"), new State(), null);
    MessageContext<AuthenticationResponse> messageContext = new MessageContext<>();
    messageContext.setMessage(resp);
    MockHttpServletResponse response = new MockHttpServletResponse();

    OIDCAuthenticationResponseEncoder encoder = new OIDCAuthenticationResponseEncoder();
    encoder.setMessageContext(messageContext);
    encoder.setHttpServletResponse(response);

    encoder.initialize();
    encoder.encode();

    Assert.assertEquals("UTF-8", response.getCharacterEncoding(), "Unexpected character encoding");
    Assert.assertEquals(response.getHeader("Cache-control"), "no-cache, no-store", "Unexpected cache controls");

}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:21,代码来源:OIDCAuthenticationResponseEncoderTest.java


示例2: userInfoRequest

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
@Override
public void userInfoRequest(RequestPath path, HttpServletRequest req, HttpServletResponse resp) throws IOException {
	try {
		logger.log("User Info requested.");

		HTTPRequest httpReq = ServletUtils.createHTTPRequest(req);
		UserInfoRequest userReq = UserInfoRequest.parse(httpReq);
		logger.logHttpRequest(req, httpReq.getQuery());
		
		UserInfoSuccessResponse uiResp = userInfoRequestInt(userReq, resp);
		if (uiResp != null) {
			sendResponse("User Info", uiResp, resp);
		}
	} catch (ParseException ex) {
		logger.log("Error parsing User Info Request.", ex);
		ErrorObject error = ex.getErrorObject();
		BearerTokenError be = new BearerTokenError(error.getCode(), error.getDescription(), error.getHTTPStatusCode());
		UserInfoErrorResponse errorResp = new UserInfoErrorResponse(be);
		sendErrorResponse("User Info", errorResp, resp);
	}
}
 
开发者ID:RUB-NDS,项目名称:PrOfESSOS,代码行数:22,代码来源:DefaultOP.java


示例3: registerClient

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
/**
	 * Client registration
	 * If the provider supports dynamic registration, a new client can be registered using the client registration process:
	 * 
	 * @param initialAccessToken the initial access token
	 * @throws SerializeException the serialize exception
	 * @throws IOException Signals that an I/O exception has occurred.
	 * @throws ParseException the parse exception
	 * @throws KeyStoreException
	 * @throws CertificateException
	 * @throws NoSuchAlgorithmException
	 * @throws KeyManagementException
	 */
	public void registerClient(BearerAccessToken initialAccessToken) throws SerializeException, IOException, ParseException, KeyManagementException, NoSuchAlgorithmException, CertificateException, KeyStoreException {

//		System.out.println("Client metadata");
//		System.out.println(metadata.toJSONObject());

		// Make registration request
		OIDCClientRegistrationRequest registrationRequest = new OIDCClientRegistrationRequest(providerMetadata.getRegistrationEndpointURI(), clientMetadata, initialAccessToken);
		HTTPResponse regHTTPResponse = registrationRequest.toHTTPRequest().send(null, Trust.getSocketFactory(trustStoreFile));

		// Parse and check response
		ClientRegistrationResponse registrationResponse = OIDCClientRegistrationResponseParser.parse(regHTTPResponse);

		if (registrationResponse instanceof ClientRegistrationErrorResponse) {
			ClientRegistrationErrorResponse errorResponse = ((ClientRegistrationErrorResponse) registrationResponse);
			ErrorObject error = errorResponse.getErrorObject();
			System.err.println(this.getClass().getSimpleName() + " - " + errorResponse.indicatesSuccess());
			System.err.println("Dynamic Client Registration failed, Error:");
			System.err.println(errorResponse);
			System.err.println(error);
			System.err.println(regHTTPResponse.getStatusCode());
			System.err.println(regHTTPResponse.getContent());
			System.err.println(regHTTPResponse.getWWWAuthenticate());
			System.err.println(regHTTPResponse.getLocation());
		} else {
			clientInformation = ((OIDCClientInformationResponse) registrationResponse).getOIDCClientInformation();
			clientID = clientInformation.getID();
		}
	}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:42,代码来源:SimpleOIDCClient.java


示例4: processAuthenticationResponse

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
/**
 * Receive the Authentication Response
 * The authentication response is sent from the provider by redirecting the end user to the redirect URI specified in the initial authentication request from the client.
 * Code flow
 * The Authorization Code can be extracted from the query part of the redirect URL:
 *
 * @param responseURL the response URL
 */
public void processAuthenticationResponse(String responseURL) {
	
	AuthenticationResponse authResp = null;
	try {
		authResp = AuthenticationResponseParser.parse(new URI(responseURL));
	} catch (ParseException | URISyntaxException e) {
		e.printStackTrace();

	}

	if (authResp instanceof AuthenticationErrorResponse) {
		AuthenticationErrorResponse errorResponse = (AuthenticationErrorResponse) authResp;
		ErrorObject error = errorResponse.getErrorObject();
		System.err.println(this.getClass().getSimpleName() + " - Authentication failed! Error:");
		System.err.println(errorResponse.indicatesSuccess());
		System.err.println(errorResponse);
		System.err.println(error);
	} else {
		/* Don't forget to check the state!
		 * The state in the received authentication response must match the state
		 * specified in the previous outgoing authentication request.
		 */
		AuthenticationSuccessResponse successResponse = (AuthenticationSuccessResponse) authResp;
		if (!this.verifyState(successResponse.getState())) {
			System.err.println(this.getClass().getSimpleName() + " - " + "State not valid");
			return;
		}
		authCode = successResponse.getAuthorizationCode();
		System.out.println("Authorization Code: " + authCode);
		
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:41,代码来源:SimpleOIDCClient.java


示例5: requestUserInfo

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
/**
 * UserInfo Request
 * Using the access token, information about the end user can be obtained by making a user info request
 * 
 * @throws KeyStoreException
 * @throws CertificateException
 * @throws NoSuchAlgorithmException
 * @throws KeyManagementException
 * @throws ParseException
 * @throws IOException
 * @throws FileNotFoundException
 */
public void requestUserInfo() throws KeyManagementException, NoSuchAlgorithmException, CertificateException, KeyStoreException, ParseException, FileNotFoundException, IOException {
	if (accessToken == null) {
		System.err.println(this.getClass().getSimpleName() + " - Access Token null, stopping UserInfo retrieval");
		return;
	}

	UserInfoRequest userInfoReq = new UserInfoRequest(
			userInfoEndpointURI,
			(BearerAccessToken) accessToken);

	HTTPResponse userInfoHTTPResp = null;
	userInfoHTTPResp = userInfoReq.toHTTPRequest().send(null, Trust.getSocketFactory(trustStoreFile));

	UserInfoResponse userInfoResponse = null;
	userInfoResponse = UserInfoResponse.parse(userInfoHTTPResp);

	if (userInfoResponse instanceof UserInfoErrorResponse) {
		UserInfoErrorResponse errorResponse = ((UserInfoErrorResponse) userInfoResponse);
		ErrorObject error = errorResponse.getErrorObject();

		System.err.println(this.getClass().getSimpleName() + " - " + errorResponse.indicatesSuccess());
		System.err.println("Userinfo retrieval failed:");
		System.err.println(errorResponse);
		System.err.println(error);
		System.err.println(error.getHTTPStatusCode());
		System.err.println(userInfoHTTPResp.getStatusCode());
		System.err.println(userInfoHTTPResp.getContent());
		System.err.println(userInfoHTTPResp.getWWWAuthenticate());
		System.err.println(userInfoHTTPResp.getLocation());
	}

	UserInfoSuccessResponse successResponse = (UserInfoSuccessResponse) userInfoResponse;
	userInfoClaims = successResponse.getUserInfo().toJSONObject();
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:47,代码来源:SimpleOIDCClient.java


示例6: authCode_withPromptNoneAndNoAuthentication_isError

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
@Test
public void authCode_withPromptNoneAndNoAuthentication_isError() throws Exception {
	ErrorObject error = OIDCError.LOGIN_REQUIRED;

	given(this.clientRepository.findById(any(ClientID.class))).willReturn(authCodeClient());

	MockHttpServletRequestBuilder request = get(
			"/oauth2/authorize?scope=openid&response_type=code&client_id=test-client&redirect_uri=http://example.com&prompt=none")
					.session(this.session);
	this.mvc.perform(request).andExpect(status().isFound())
			.andExpect(redirectedUrlPattern("http://example.com?error_description=*&error=" + error.getCode()));
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:13,代码来源:AuthorizationEndpointTests.java


示例7: authCode_withoutScope_isError

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
@Test
public void authCode_withoutScope_isError() throws Exception {
	ErrorObject error = OAuth2Error.INVALID_REQUEST;

	given(this.clientRepository.findById(any(ClientID.class))).willReturn(authCodeClient());

	MockHttpServletRequestBuilder request = get(
			"/oauth2/authorize?response_type=code&client_id=test-client&redirect_uri=http://example.com")
					.session(this.session);
	this.mvc.perform(request).andExpect(status().isFound())
			.andExpect(redirectedUrlPattern("http://example.com?error_description=*&error=" + error.getCode()));
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:13,代码来源:AuthorizationEndpointTests.java


示例8: authCode_withInvalidScope_isError

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
@Test
public void authCode_withInvalidScope_isError() throws Exception {
	ErrorObject error = OAuth2Error.INVALID_REQUEST;

	given(this.clientRepository.findById(any(ClientID.class))).willReturn(authCodeClient());

	MockHttpServletRequestBuilder request = get(
			"/oauth2/authorize?scope=test&response_type=code&client_id=test-client&redirect_uri=http://example.com")
					.session(this.session);
	this.mvc.perform(request).andExpect(status().isFound())
			.andExpect(redirectedUrlPattern("http://example.com?error_description=*&error=" + error.getCode()));
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:13,代码来源:AuthorizationEndpointTests.java


示例9: implicitWithIdTokenAndToken_withoutScope_isError

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
@Test
public void implicitWithIdTokenAndToken_withoutScope_isError() throws Exception {
	ErrorObject error = OAuth2Error.INVALID_REQUEST;

	given(this.clientRepository.findById(any(ClientID.class))).willReturn(implicitWithIdTokenAndTokenClient());

	MockHttpServletRequestBuilder request = get(
			"/oauth2/authorize?response_type=id_token token&client_id=test-client&redirect_uri=http://example.com")
					.session(this.session);
	this.mvc.perform(request).andExpect(status().isFound())
			.andExpect(redirectedUrlPattern("http://example.com?error_description=*&error=" + error.getCode()));
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:13,代码来源:AuthorizationEndpointTests.java


示例10: implicitWithIdTokenAndToken_withoutNonce_isError

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
@Test
public void implicitWithIdTokenAndToken_withoutNonce_isError() throws Exception {
	ErrorObject error = OAuth2Error.INVALID_REQUEST;

	given(this.clientRepository.findById(any(ClientID.class))).willReturn(implicitWithIdTokenAndTokenClient());

	MockHttpServletRequestBuilder request = get(
			"/oauth2/authorize?scope=openid&response_type=id_token token&client_id=test-client&redirect_uri=http://example.com")
					.session(this.session);
	this.mvc.perform(request).andExpect(status().isFound())
			.andExpect(redirectedUrlPattern("http://example.com?error_description=*&error=" + error.getCode()));
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:13,代码来源:AuthorizationEndpointTests.java


示例11: invalid_withoutResponseType_isError

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
@Test
public void invalid_withoutResponseType_isError() throws Exception {
	ErrorObject error = OAuth2Error.INVALID_REQUEST;

	given(this.clientRepository.findById(any(ClientID.class))).willReturn(authCodeClient());

	MockHttpServletRequestBuilder request = get(
			"/oauth2/authorize?scope=openid&client_id=test-client&redirect_uri=http://example.com")
					.session(this.session);
	this.mvc.perform(request).andExpect(status().isFound())
			.andExpect(redirectedUrlPattern("http://example.com?error_description=*&error=" + error.getCode()));
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:13,代码来源:AuthorizationEndpointTests.java


示例12: tokenRequest

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
@Override
public void tokenRequest(RequestPath path, HttpServletRequest req, HttpServletResponse resp) throws IOException {
	CompletableFuture<TestStepResult> blocker = (CompletableFuture<TestStepResult>) stepCtx.get(OPContextConstants.BLOCK_BROWSER_AND_TEST_RESULT);

	try {
		logger.log("Token requested.");

		HTTPRequest httpReq = ServletUtils.createHTTPRequest(req);
		TokenRequest tokenReq = TokenRequest.parse(httpReq);
		logger.logHttpRequest(req, httpReq.getQuery());

		if (type == OPType.EVIL) {
			AuthorizationGrant grant = tokenReq.getAuthorizationGrant();
			if (grant != null && grant.getType() == GrantType.AUTHORIZATION_CODE) {
				AuthorizationCodeGrant codeGrant = (AuthorizationCodeGrant) grant;
				AuthorizationCode code = codeGrant.getAuthorizationCode();
				// TODO compare actual code
				AuthorizationCode honestCode = (AuthorizationCode) stepCtx.get(OPContextConstants.HONEST_CODE);
				if (code.equals(honestCode)) {
					logger.log("Honest code received in attacker.");
					blocker.complete(TestStepResult.FAIL);
				} else {
					logger.log("Honest code not received in attacker.");
					blocker.complete(TestStepResult.PASS);
				}

				return;
			}
		}

		blocker.complete(TestStepResult.PASS);
	} catch (ParseException ex) {
		ErrorObject error = OAuth2Error.INVALID_REQUEST;
		TokenErrorResponse errorResp = new TokenErrorResponse(error);
		sendErrorResponse("Token", errorResp, resp);
		blocker.complete(TestStepResult.UNDETERMINED);
	}

}
 
开发者ID:RUB-NDS,项目名称:PrOfESSOS,代码行数:40,代码来源:IdPConfusionOP.java


示例13: processOIDCAuthResponse

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
protected AuthenticationMechanismOutcome processOIDCAuthResponse(HttpServerExchange exchange) {
	try {
		AuthenticationResponse authResp = authenticate(exchange);

		if (authResp instanceof AuthenticationErrorResponse) {
			ErrorObject error = ((AuthenticationErrorResponse) authResp).getErrorObject();
			throw new IllegalStateException(String.format("OIDC Authentication error: code %s description: %s", error.getCode(), error.getDescription()));
		}

		AuthenticationSuccessResponse successResponse = (AuthenticationSuccessResponse) authResp;

		// could store returnURL/state
		// in session but state is encrypted
		State state = successResponse.getState();
		String returnURL = restoreState(state != null ? state.getValue() : null, exchange);

		AuthorizationCode authCode = successResponse.getAuthorizationCode();
		JWT idToken = successResponse.getIDToken();
		AccessToken accessToken = successResponse.getAccessToken();

		if (idToken == null && authCode != null) {
			OIDCTokenResponse tokenResponse = fetchToken(authCode, exchange);
			idToken = tokenResponse.getOIDCTokens().getIDToken();
			accessToken = tokenResponse.getOIDCTokens().getAccessToken();
		}
		validateToken(idToken, exchange, true);
		return complete(idToken.getJWTClaimsSet(), accessToken, returnURL, exchange, true);

	} catch (Exception e) {
		LOG.log(Level.SEVERE, "", e);
		OIDCContext oidcContext = exchange.getAttachment(OIDCContext.ATTACHMENT_KEY);
		oidcContext.setError(true);
		exchange.getSecurityContext().authenticationFailed("OIDC auth response processing failed", mechanismName);
		return AuthenticationMechanismOutcome.NOT_ATTEMPTED;
	}

}
 
开发者ID:aaronanderson,项目名称:swarm-oidc,代码行数:38,代码来源:OIDCAuthenticationMechanism.java


示例14: fetchToken

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
protected OIDCTokenResponse fetchToken(AuthorizationCode authCode, HttpServerExchange exchange) throws Exception {
	URI redirectURI = new URI(RedirectBuilder.redirect(exchange, redirectPath));
	TokenRequest tokenReq = new TokenRequest(oidcProvider.getTokenURI(), oidcProvider.getClientId(), new AuthorizationCodeGrant(authCode, redirectURI));
	HTTPResponse tokenHTTPResp = tokenReq.toHTTPRequest().send();
	TokenResponse tokenResponse = OIDCTokenResponseParser.parse(tokenHTTPResp);
	if (tokenResponse instanceof TokenErrorResponse) {
		ErrorObject error = ((TokenErrorResponse) tokenResponse).getErrorObject();
		throw new IllegalStateException(String.format("OIDC TokenRequest error: code %s description: %s", error.getCode(), error.getDescription()));
	}
	return (OIDCTokenResponse) tokenResponse;
}
 
开发者ID:aaronanderson,项目名称:swarm-oidc,代码行数:12,代码来源:OIDCAuthenticationMechanism.java


示例15: fetchProfile

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
protected UserInfoSuccessResponse fetchProfile(BearerAccessToken accessToken) throws Exception {
	UserInfoRequest userInfoReq = new UserInfoRequest(oidcProvider.getUserInfoURI(), accessToken);
	HTTPResponse userInfoHTTPResp = userInfoReq.toHTTPRequest().send();
	UserInfoResponse userInfoResponse = UserInfoResponse.parse(userInfoHTTPResp);
	if (userInfoResponse instanceof UserInfoErrorResponse) {
		ErrorObject error = ((UserInfoErrorResponse) userInfoResponse).getErrorObject();
		throw new IllegalStateException(String.format("OIDC UserInfoRequest error: code %s description: %s", error.getCode(), error.getDescription()));
	}
	return (UserInfoSuccessResponse) userInfoResponse;
}
 
开发者ID:aaronanderson,项目名称:swarm-oidc,代码行数:11,代码来源:OIDCAuthenticationMechanism.java


示例16: setMappedErrors

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
/**
 * Set map of eventIds to pre-configured error objects.
 * @param errors map of eventIds to pre-configured error objects.
 */
public void setMappedErrors(@Nonnull final Map<String, ErrorObject> errors) {
    ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);

    mappedErrors = Constraint.isNotNull(errors, "Mapped errors cannot be null");
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:10,代码来源:BuildRegistrationErrorResponseFromEvent.java


示例17: NonRedirectingException

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
NonRedirectingException(ErrorObject error) {
	this(error.getHTTPStatusCode(), error.getDescription());
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:4,代码来源:NonRedirectingException.java


示例18: getError

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
/**
 * @return error object, used to encapsulate OAuth 2.0 and other errors.
 */
public ErrorObject getError()
{
    return this.error;
}
 
开发者ID:xwiki-contrib,项目名称:oidc,代码行数:8,代码来源:OIDCException.java


示例19: OIDCException

import com.nimbusds.oauth2.sdk.ErrorObject; //导入依赖的package包/类
/**
 * Constructs a new exception with the specified detail message. The cause is not initialized, and may subsequently
 * be initialized by a call to {@link #initCause(Throwable)}.
 *
 * @param message the detail message (which is saved for later retrieval by the {@link #getMessage()} method)
 * @param error error object, used to encapsulate OAuth 2.0 and other errors.
 */
public OIDCException(String message, ErrorObject error)
{
    super(error != null ? message + ':' + error.toString() : message);

    this.error = error;
}
 
开发者ID:xwiki-contrib,项目名称:oidc,代码行数:14,代码来源:OIDCException.java



注:本文中的com.nimbusds.oauth2.sdk.ErrorObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ConnectableFlux类代码示例发布时间:2022-05-22
下一篇:
Java WordFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap