本文整理汇总了Java中org.jasig.cas.support.oauth.OAuthUtils.writeTextError方法的典型用法代码示例。如果您正苦于以下问题:Java OAuthUtils.writeTextError方法的具体用法?Java OAuthUtils.writeTextError怎么用?Java OAuthUtils.writeTextError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jasig.cas.support.oauth.OAuthUtils
的用法示例。
在下文中一共展示了OAuthUtils.writeTextError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: internalHandleRequest
import org.jasig.cas.support.oauth.OAuthUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView internalHandleRequest(final String method, final HttpServletRequest request,
final HttpServletResponse response) throws Exception {
// authorize
if (OAuthConstants.AUTHORIZE_URL.equals(method)) {
return authorizeController.handleRequest(request, response);
}
// callback on authorize
if (OAuthConstants.CALLBACK_AUTHORIZE_URL.equals(method)) {
return callbackAuthorizeController.handleRequest(request, response);
}
//get access token
if (OAuthConstants.ACCESS_TOKEN_URL.equals(method)) {
return accessTokenController.handleRequest(request, response);
}
// get profile
if (OAuthConstants.PROFILE_URL.equals(method)) {
return profileController.handleRequest(request, response);
}
// else error
logger.error("Unknown method : {}", method);
OAuthUtils.writeTextError(response, OAuthConstants.INVALID_REQUEST, HttpStatus.SC_OK);
return null;
}
示例2: internalHandleRequest
import org.jasig.cas.support.oauth.OAuthUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView internalHandleRequest(final String method, final HttpServletRequest request,
final HttpServletResponse response) throws Exception {
// authorize
if (OAuthConstants.AUTHORIZE_URL.equals(method)) {
return authorizeController.handleRequest(request, response);
}
// callback on authorize
if (OAuthConstants.CALLBACK_AUTHORIZE_URL.equals(method)) {
return callbackAuthorizeController.handleRequest(request, response);
}
//get access token
if (OAuthConstants.ACCESS_TOKEN_URL.equals(method)) {
return accessTokenController.handleRequest(request, response);
}
// get profile
if (OAuthConstants.PROFILE_URL.equals(method)) {
return profileController.handleRequest(request, response);
}
// else error
logger.error("Unknown method : {}", method);
OAuthUtils.writeTextError(response, OAuthConstants.INVALID_REQUEST, 200);
return null;
}
示例3: handleRequestInternal
import org.jasig.cas.support.oauth.OAuthUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
final String redirectUri = request.getParameter(OAuthConstants.REDIRECT_URI);
LOGGER.debug("{} : {}", OAuthConstants.REDIRECT_URI, redirectUri);
final String clientId = request.getParameter(OAuthConstants.CLIENT_ID);
LOGGER.debug("{} : {}", OAuthConstants.CLIENT_ID, clientId);
final String clientSecret = request.getParameter(OAuthConstants.CLIENT_SECRET);
final String code = request.getParameter(OAuthConstants.CODE);
LOGGER.debug("{} : {}", OAuthConstants.CODE, code);
final boolean isVerified = verifyAccessTokenRequest(response, redirectUri, clientId, clientSecret, code);
if (!isVerified) {
return OAuthUtils.writeTextError(response, OAuthConstants.INVALID_REQUEST, HttpStatus.SC_BAD_REQUEST);
}
final ServiceTicket serviceTicket = (ServiceTicket) ticketRegistry.getTicket(code);
// service ticket should be valid
if (serviceTicket == null || serviceTicket.isExpired()) {
LOGGER.error("Code expired : {}", code);
return OAuthUtils.writeTextError(response, OAuthConstants.INVALID_GRANT, HttpStatus.SC_BAD_REQUEST);
}
final TicketGrantingTicket ticketGrantingTicket = serviceTicket.getGrantingTicket();
// remove service ticket
ticketRegistry.deleteTicket(serviceTicket.getId());
response.setContentType("text/plain");
final int expires = (int) (timeout - TimeUnit.MILLISECONDS
.toSeconds(System.currentTimeMillis() - ticketGrantingTicket.getCreationTime()));
final String text = String.format("%s=%s&%s=%s", OAuthConstants.ACCESS_TOKEN, ticketGrantingTicket.getId(),
OAuthConstants.EXPIRES, expires);
LOGGER.debug("text : {}", text);
return OAuthUtils.writeText(response, text, HttpStatus.SC_OK);
}
示例4: handleRequestInternal
import org.jasig.cas.support.oauth.OAuthUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
final String redirectUri = request.getParameter(OAuthConstants.REDIRECT_URI);
LOGGER.debug("{} : {}", OAuthConstants.REDIRECT_URI, redirectUri);
final String clientId = request.getParameter(OAuthConstants.CLIENT_ID);
LOGGER.debug("{} : {}", OAuthConstants.CLIENT_ID, clientId);
final String clientSecret = request.getParameter(OAuthConstants.CLIENT_SECRET);
final String code = request.getParameter(OAuthConstants.CODE);
LOGGER.debug("{} : {}", OAuthConstants.CODE, code);
final boolean isVerified = verifyAccessTokenRequest(response, redirectUri, clientId, clientSecret, code);
if (!isVerified) {
return OAuthUtils.writeTextError(response, OAuthConstants.INVALID_REQUEST, 400);
}
final ServiceTicket serviceTicket = (ServiceTicket) ticketRegistry.getTicket(code);
// service ticket should be valid
if (serviceTicket == null || serviceTicket.isExpired()) {
LOGGER.error("Code expired : {}", code);
return OAuthUtils.writeTextError(response, OAuthConstants.INVALID_GRANT, 400);
}
final TicketGrantingTicket ticketGrantingTicket = serviceTicket.getGrantingTicket();
// remove service ticket
ticketRegistry.deleteTicket(serviceTicket.getId());
response.setContentType("text/plain");
final int expires = (int) (timeout - (System.currentTimeMillis()
- ticketGrantingTicket.getCreationTime()) / 1000);
final String text = String.format("%s=%s&%s=%s", OAuthConstants.ACCESS_TOKEN, ticketGrantingTicket.getId(),
OAuthConstants.EXPIRES, expires);
LOGGER.debug("text : {}", text);
return OAuthUtils.writeText(response, text, 200);
}
示例5: internalHandleRequest
import org.jasig.cas.support.oauth.OAuthUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView internalHandleRequest(final String method, final HttpServletRequest request,
final HttpServletResponse response) throws Exception {
final String redirectUri = request.getParameter(OAuthConstants.REDIRECT_URI);
logger.debug("{} : {}", OAuthConstants.REDIRECT_URI, redirectUri);
final String clientId = request.getParameter(OAuthConstants.CLIENT_ID);
logger.debug("{} : {}", OAuthConstants.CLIENT_ID, clientId);
final String clientSecret = request.getParameter(OAuthConstants.CLIENT_SECRET);
final String code = request.getParameter(OAuthConstants.CODE);
logger.debug("{} : {}", OAuthConstants.CODE, code);
final boolean isVerified = verifyAccessTokenRequest(response, redirectUri, clientId, clientSecret, code);
if (!isVerified) {
return OAuthUtils.writeTextError(response, OAuthConstants.INVALID_REQUEST, HttpStatus.SC_BAD_REQUEST);
}
final ServiceTicket serviceTicket = (ServiceTicket) ticketRegistry.getTicket(code);
// service ticket should be valid
if (serviceTicket == null || serviceTicket.isExpired()) {
logger.error("Code expired : {}", code);
return OAuthUtils.writeTextError(response, OAuthConstants.INVALID_GRANT, HttpStatus.SC_BAD_REQUEST);
}
final TicketGrantingTicket ticketGrantingTicket = serviceTicket.getGrantingTicket();
// remove service ticket
ticketRegistry.deleteTicket(serviceTicket.getId());
final OAuthRegisteredService registeredService = OAuthUtils.getRegisteredOAuthService(this.servicesManager, clientId);
final OAuthWebApplicationService service = new OAuthWebApplicationService(registeredService.getId());
final String accessTokenEncoded = this.accessTokenGenerator.generate(service, ticketGrantingTicket);
final int expires = (int) (this.timeout - TimeUnit.MILLISECONDS
.toSeconds(System.currentTimeMillis() - ticketGrantingTicket.getCreationTime()));
final String text = String.format("%s=%s&%s=%s", OAuthConstants.ACCESS_TOKEN, accessTokenEncoded, OAuthConstants.EXPIRES, expires);
logger.debug("OAuth access token response: {}", text);
response.setContentType("text/plain");
return OAuthUtils.writeText(response, text, HttpStatus.SC_OK);
}
示例6: internalHandleRequest
import org.jasig.cas.support.oauth.OAuthUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView internalHandleRequest(final String method, final HttpServletRequest request,
final HttpServletResponse response) throws Exception {
final String redirectUri = request.getParameter(OAuthConstants.REDIRECT_URI);
logger.debug("{} : {}", OAuthConstants.REDIRECT_URI, redirectUri);
final String clientId = request.getParameter(OAuthConstants.CLIENT_ID);
logger.debug("{} : {}", OAuthConstants.CLIENT_ID, clientId);
final String clientSecret = request.getParameter(OAuthConstants.CLIENT_SECRET);
final String code = request.getParameter(OAuthConstants.CODE);
logger.debug("{} : {}", OAuthConstants.CODE, code);
final boolean isVerified = verifyAccessTokenRequest(response, redirectUri, clientId, clientSecret, code);
if (!isVerified) {
return OAuthUtils.writeTextError(response, OAuthConstants.INVALID_REQUEST, HttpStatus.SC_BAD_REQUEST);
}
final ServiceTicket serviceTicket = (ServiceTicket) ticketRegistry.getTicket(code);
// service ticket should be valid
if (serviceTicket == null || serviceTicket.isExpired()) {
logger.error("Code expired : {}", code);
return OAuthUtils.writeTextError(response, OAuthConstants.INVALID_GRANT, HttpStatus.SC_BAD_REQUEST);
}
final TicketGrantingTicket ticketGrantingTicket = serviceTicket.getGrantingTicket();
// remove service ticket
ticketRegistry.deleteTicket(serviceTicket.getId());
final OAuthRegisteredService registeredService = OAuthUtils.getRegisteredOAuthService(this.servicesManager, clientId);
final OAuthWebApplicationService service = new OAuthWebApplicationService(registeredService.getId());
final String accessTokenEncoded = this.accessTokenGenerator.generate(service, ticketGrantingTicket);
final int expires = (int) (this.timeout - TimeUnit.MILLISECONDS
.toSeconds(System.currentTimeMillis() - ticketGrantingTicket.getCreationTime()));
final String text = String.format("%s=%s&%s=%s", OAuthConstants.ACCESS_TOKEN,
accessTokenEncoded, OAuthConstants.EXPIRES_IN, expires);
logger.debug("OAuth access token response: {}", text);
response.setContentType("text/plain");
return OAuthUtils.writeText(response, text, HttpStatus.SC_OK);
}