use of org.openkilda.auth.model.RequestContext in project open-kilda by telstra.
the class SwitchControllerTest method init.
@Before
public void init() {
MockitoAnnotations.initMocks(this);
mockMvc = MockMvcBuilders.standaloneSetup(switchController).build();
RequestContext requestContext = new RequestContext();
requestContext.setUserId(TestIslMock.USER_ID);
when(serverContext.getRequestContext()).thenReturn(requestContext);
}
use of org.openkilda.auth.model.RequestContext in project open-kilda by telstra.
the class UserService method getLoggedInUserInfo.
/**
* Gets the logged in user info.
*
* @return the logged in user info
* @throws AccessDeniedException the access denied exception
*/
public UserInfo getLoggedInUserInfo() throws AccessDeniedException {
RequestContext requestContext = serverContext.getRequestContext();
if (requestContext.getUserId() == null) {
throw new AccessDeniedException(messageUtils.getUnauthorizedMessage());
}
UserInfo userInfo = new UserInfo();
userInfo.setUserId(requestContext.getUserId());
userInfo.setUsername(requestContext.getUserName());
userInfo.setIs2FaEnabled(requestContext.getIs2FaEnabled());
userInfo.setStatus(requestContext.getStatus());
userInfo.setName(requestContext.getFullName());
userInfo.setPermissions(requestContext.getPermissions());
return userInfo;
}
Aggregations