Search in sources :

Example 1 with Permissions

use of org.openkilda.auth.model.Permissions in project open-kilda by telstra.

the class FlowController method getFlowById.

/**
 * Get flow by Id.
 *
 * @param flowId
 *            id of flow requested.
 * @return flowInfo
 * @throws AccessDeniedException the access denied exception
 */
@RequestMapping(value = "/{flowId}", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
@Permissions(values = { IConstants.Permission.MENU_FLOWS })
@ResponseBody
public FlowInfo getFlowById(@PathVariable final String flowId, @RequestParam(name = "controller", required = false) boolean controller) throws AccessDeniedException {
    LOGGER.info("Get flow by id. Flow id: '" + flowId + "'");
    FlowInfo flowInfo = flowService.getFlowById(flowId, controller);
    return flowInfo;
}
Also used : FlowInfo(org.openkilda.model.FlowInfo) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) Permissions(org.openkilda.auth.model.Permissions) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with Permissions

use of org.openkilda.auth.model.Permissions in project open-kilda by telstra.

the class RequestInterceptor method preHandle.

@Override
public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler) throws AccessDeniedException {
    String correlationId = request.getParameter(CORRELATION_ID);
    correlationId = correlationId == null ? UUID.randomUUID().toString() : correlationId;
    HttpSession session = request.getSession();
    UserInfo userInfo = null;
    if (IConstants.SessionTimeout.TIME_IN_MINUTE == null) {
        IConstants.SessionTimeout.TIME_IN_MINUTE = Integer.valueOf(applicationSettingService.getApplicationSettings().get(ApplicationSetting.SESSION_TIMEOUT.name()));
    }
    session.setMaxInactiveInterval(IConstants.SessionTimeout.TIME_IN_MINUTE * 60);
    userInfo = (UserInfo) session.getAttribute(IConstants.SESSION_OBJECT);
    if (userInfo != null) {
        validateUser(userInfo);
        if (handler instanceof HandlerMethod) {
            HandlerMethod handlerMethod = (HandlerMethod) handler;
            Permissions permissions = handlerMethod.getMethod().getAnnotation(Permissions.class);
            if (permissions != null) {
                validateAndPopulatePermisssion(userInfo, permissions);
            }
        }
        updateRequestContext(correlationId, request, userInfo);
    } else {
        RequestContext requestContext = serverContext.getRequestContext();
        requestContext.setCorrelationId(correlationId);
    }
    return true;
}
Also used : HttpSession(javax.servlet.http.HttpSession) Permissions(org.openkilda.auth.model.Permissions) UserInfo(org.usermanagement.model.UserInfo) RequestContext(org.openkilda.auth.model.RequestContext) HandlerMethod(org.springframework.web.method.HandlerMethod)

Aggregations

Permissions (org.openkilda.auth.model.Permissions)2 HttpSession (javax.servlet.http.HttpSession)1 RequestContext (org.openkilda.auth.model.RequestContext)1 FlowInfo (org.openkilda.model.FlowInfo)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1 HandlerMethod (org.springframework.web.method.HandlerMethod)1 UserInfo (org.usermanagement.model.UserInfo)1