本文整理汇总了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);
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
}