当前位置: 首页>>代码示例>>Java>>正文


Java BearerTokenError类代码示例

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


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

示例1: getClientRegistrations

import com.nimbusds.oauth2.sdk.token.BearerTokenError; //导入依赖的package包/类
@GetMapping
public void getClientRegistrations(HttpServletRequest request, HttpServletResponse response) throws Exception {
	HTTPRequest httpRequest = ServletUtils.createHTTPRequest(request);

	try {
		String authorizationHeader = httpRequest.getAuthorization();

		if (authorizationHeader == null) {
			throw new GeneralException(BearerTokenError.INVALID_TOKEN);
		}

		BearerAccessToken requestAccessToken = BearerAccessToken.parse(authorizationHeader);
		validateAccessToken(requestAccessToken);
		List<OIDCClientInformation> clients = this.clientRepository.findAll();

		response.setContentType("application/json; charset=UTF-8");

		PrintWriter writer = response.getWriter();
		writer.print(toJsonObject(clients).toJSONString());
		writer.close();
	}
	catch (GeneralException e) {
		ClientRegistrationResponse registrationResponse = new ClientRegistrationErrorResponse(e.getErrorObject());
		ServletUtils.applyHTTPResponse(registrationResponse.toHTTPResponse(), response);
	}
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:27,代码来源:ClientRegistrationEndpoint.java

示例2: resolveAndValidateClient

import com.nimbusds.oauth2.sdk.token.BearerTokenError; //导入依赖的package包/类
private OIDCClientInformation resolveAndValidateClient(ClientID clientId, ProtectedResourceRequest request)
		throws GeneralException {
	OIDCClientInformation client = this.clientRepository.findById(clientId);

	if (client != null) {
		AccessToken requestAccessToken = request.getAccessToken();
		BearerAccessToken registrationAccessToken = client.getRegistrationAccessToken();
		BearerAccessToken apiAccessToken = this.apiAccessToken;

		if (requestAccessToken.equals(registrationAccessToken) || requestAccessToken.equals(apiAccessToken)) {
			return client;
		}
	}

	throw new GeneralException(BearerTokenError.INVALID_TOKEN);
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:17,代码来源:ClientRegistrationEndpoint.java

示例3: userInfoRequest

import com.nimbusds.oauth2.sdk.token.BearerTokenError; //导入依赖的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

示例4: userInfoRequestInt

import com.nimbusds.oauth2.sdk.token.BearerTokenError; //导入依赖的package包/类
@Nullable
protected UserInfoSuccessResponse userInfoRequestInt(UserInfoRequest userReq, HttpServletResponse resp)
		throws IOException {
	AccessToken at = userReq.getAccessToken();
	if (at == null) {
		UserInfoErrorResponse errorResp = new UserInfoErrorResponse(BearerTokenError.MISSING_TOKEN);
		sendErrorResponse("User Info", errorResp, resp);
		return null;
	}
	//AccessTokenHash atHash = AccessTokenHash.compute(at, JWSAlgorithm.RS256);

	UserInfo ui = getUserInfo();

	UserInfoSuccessResponse uiResp = new UserInfoSuccessResponse(ui);
	return uiResp;
}
 
开发者ID:RUB-NDS,项目名称:PrOfESSOS,代码行数:17,代码来源:DefaultOP.java

示例5: validateAccessToken

import com.nimbusds.oauth2.sdk.token.BearerTokenError; //导入依赖的package包/类
private void validateAccessToken(AccessToken requestAccessToken) throws GeneralException {
	BearerAccessToken apiAccessToken = this.apiAccessToken;

	if (requestAccessToken == null || !requestAccessToken.equals(apiAccessToken)) {
		throw new GeneralException(BearerTokenError.INVALID_TOKEN);
	}
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:8,代码来源:ClientRegistrationEndpoint.java


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