Source:
<code>public void interceptWithAccessTokenTest() throws IOException, DotSecurityException, DotDataException { loginService = mock(LoginServiceAPI.class); jsonWebTokenService = JsonWebTokenFactory.getInstance().getJsonWebTokenService(); final JsonWebTokenInterceptor jsonWebTokenInterceptor = new JsonWebTokenInterceptor(jsonWebTokenService, null, null, loginService, null); when(loginService.isLoggedIn(request)).thenReturn(false); final User user = APILocator.getUserAPI().loadUserById(userId); <START> final UserToken userToken = new UserToken(jwtId, userId, date, date.getTime(), user.getSkinId()); <END> final String jsonWebToken = jsonWebTokenService.generateUserToken(userToken); when(request.getSession(false)).thenReturn(session); when(session.getAttribute(WebKeys.USER_ID)).thenReturn(null); when(request.isSecure()).thenReturn(true); when(request.getCookies()).thenAnswer(new Answer<Cookie[]>() { @Override public Cookie[] answer(InvocationOnMock invocation) throws Throwable { System.out.println("getting the access token:" + jsonWebToken); return new Cookie[] { new Cookie(CookieKeys.JWT_ACCESS_TOKEN, jsonWebToken) }; } }); when(loginService.doCookieLogin(anyObject(), anyObject(), anyObject())).thenAnswer(new Answer<Boolean>() { @Override public Boolean answer(InvocationOnMock invocation) throws Throwable { System.out.println("Success calling the do cookie for a valid scenario"); calledDoCookieLogin = true; return true; } }); jsonWebTokenInterceptor.setCompanyLocalManager(companyLocalManager); jsonWebTokenInterceptor.setEncryptor(encryptor); jsonWebTokenInterceptor.setLoginService(loginService); jsonWebTokenInterceptor.setUserAPI(userAPI); jsonWebTokenInterceptor.init(); jsonWebTokenInterceptor.intercept(request, response); jsonWebTokenInterceptor.destroy(); if (!calledDoCookieLogin) { fail("Failed. doCookieLogin must be called on successfully scenario..."); } }</code><technical_language>Question - of user.skinId token id instead of adding another claim token? I - moving parts. a user logs in, get a user token id out of user.skinId. If invalidated/updated, tokens invalidated, right</technical_language>

Target:
public void interceptWithAccessTokenTest() throws IOException, DotSecurityException, DotDataException { loginService = mock(LoginServiceAPI.class); jsonWebTokenService = JsonWebTokenFactory.getInstance().getJsonWebTokenService(); final JsonWebTokenInterceptor jsonWebTokenInterceptor = new JsonWebTokenInterceptor(jsonWebTokenService, null, null, loginService, null); when(loginService.isLoggedIn(request)).thenReturn(false); final User user = APILocator.getUserAPI().loadUserById(userId); final String jwtId = user.getRememberMeToken(); final UserToken userToken = new UserToken.Builder().id(jwtId).subject(userId).modificationDate(date) .expiresDate(date.getTime()).build(); final String jsonWebToken = jsonWebTokenService.generateUserToken(userToken); when(request.getSession(false)).thenReturn(session); when(session.getAttribute(WebKeys.USER_ID)).thenReturn(null); when(request.isSecure()).thenReturn(true); when(request.getCookies()).thenAnswer(new Answer<Cookie[]>() { @Override public Cookie[] answer(InvocationOnMock invocation) throws Throwable { System.out.println("getting the access token:" + jsonWebToken); return new Cookie[] { new Cookie(CookieKeys.JWT_ACCESS_TOKEN, jsonWebToken) }; } }); when(loginService.doCookieLogin(anyObject(), anyObject(), anyObject())).thenAnswer(new Answer<Boolean>() { @Override public Boolean answer(InvocationOnMock invocation) throws Throwable { System.out.println("Success calling the do cookie for a valid scenario"); calledDoCookieLogin = true; return true; } }); jsonWebTokenInterceptor.setCompanyLocalManager(companyLocalManager); jsonWebTokenInterceptor.setEncryptor(encryptor); jsonWebTokenInterceptor.setLoginService(loginService); jsonWebTokenInterceptor.setUserAPI(userAPI); jsonWebTokenInterceptor.init(); jsonWebTokenInterceptor.intercept(request, response); jsonWebTokenInterceptor.destroy(); if (!calledDoCookieLogin) { fail("Failed. doCookieLogin must be called on successfully scenario..."); } }