Search in sources :

Example 1 with RequestReturnAdviceException

use of org.b3log.latke.servlet.advice.RequestReturnAdviceException in project solo by b3log.

the class ProcessAuthAdvice method doAdvice.

@Override
public void doAdvice(final HTTPRequestContext context, final Map<String, Object> args) throws RequestProcessAdviceException {
    final LatkeBeanManager beanManager = Lifecycle.getBeanManager();
    final UserQueryService userQueryService = beanManager.getReference(UserQueryService.class);
    if (!userQueryService.isLoggedIn(context.getRequest(), context.getResponse())) {
        try {
            context.getResponse().sendError(HttpServletResponse.SC_FORBIDDEN);
        } catch (final IOException e) {
            throw new RuntimeException(e);
        }
        throw new RequestReturnAdviceException(null);
    }
}
Also used : RequestReturnAdviceException(org.b3log.latke.servlet.advice.RequestReturnAdviceException) UserQueryService(org.b3log.solo.service.UserQueryService) IOException(java.io.IOException) LatkeBeanManager(org.b3log.latke.ioc.LatkeBeanManager)

Aggregations

IOException (java.io.IOException)1 LatkeBeanManager (org.b3log.latke.ioc.LatkeBeanManager)1 RequestReturnAdviceException (org.b3log.latke.servlet.advice.RequestReturnAdviceException)1 UserQueryService (org.b3log.solo.service.UserQueryService)1