本文整理了Java中org.apache.catalina.connector.Request.getNote
方法的一些代码示例,展示了Request.getNote
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getNote
方法的具体详情如下:
包路径:org.apache.catalina.connector.Request
类名称:Request
方法名:getNote
[英]Return the object bound with the specified name to the internal notes for this request, or null
if no such binding exists.
[中]将使用指定名称绑定的对象返回到此请求的内部注释,如果不存在此类绑定,则返回null
。
代码示例来源:origin: magro/memcached-session-manager
public boolean wasInvokedWith(final Request currentRequest) {
return currentRequest != null && currentRequest.getNote(INVOKED) == Boolean.TRUE;
}
代码示例来源:origin: magro/memcached-session-manager
public boolean isIgnoredRequest() {
final Request request = _currentRequest.get();
return request != null && request.getNote(REQUEST_IGNORED) == Boolean.TRUE;
}
代码示例来源:origin: magro/memcached-session-manager
private String getSessionId(final Request request, final Response response) {
// If the context is configured with cookie="false" there's no session cookie
// sent so we must rely on data from MemcachedSessionService
String sessionId = (String) request.getNote(MemcachedSessionService.NEW_SESSION_ID);
if(sessionId == null) {
sessionId = getSessionIdFromResponseSessionCookie( response );
}
return sessionId != null ? sessionId : request.getRequestedSessionId();
}
代码示例来源:origin: magro/memcached-session-manager
@Nonnull
protected static String getURIWithQueryString( @Nonnull final Request request ) {
final Object note = request.getNote(MSM_REQUEST_ID);
if(note != null) {
// we have a string and want to save cast
return note.toString();
}
final StringBuilder sb = new StringBuilder(30);
sb.append(request.getMethod())
.append(' ')
.append(request.getRequestURI());
if(!isPostMethod(request) && request.getQueryString() != null) {
sb.append('?').append(request.getQueryString());
}
final String result = sb.toString();
request.setNote(MSM_REQUEST_ID, result);
return result;
}
代码示例来源:origin: magro/memcached-session-manager
@BeforeMethod
public void setUp() throws Exception {
_service = mock( MemcachedSessionService.class );
_sessionTrackerValve = createSessionTrackerValve();
_nextValve = mock( Valve.class );
_sessionTrackerValve.setNext( _nextValve );
_request = mock( Request.class );
_response = mock( Response.class );
when(_request.getNote(eq(RequestTrackingHostValve.REQUEST_PROCESS))).thenReturn(Boolean.TRUE);
}
代码示例来源:origin: magro/memcached-session-manager
@Test
public final void testChangeSessionIdForRelocatedSession() throws IOException, ServletException {
final String sessionId = "bar";
final String newSessionId = "newId";
when(_request.getNote(eq(RequestTrackingHostValve.SESSION_ID_CHANGED))).thenReturn(Boolean.TRUE);
when( _request.getRequestedSessionId() ).thenReturn( sessionId );
final Cookie cookie = new Cookie( _sessionTrackerValve.getSessionCookieName(), newSessionId );
setupGetResponseSetCookieHeadersExpectations(_response, new String[]{generateCookieString( cookie )});
_sessionTrackerValve.invoke( _request, _response );
verify( _service ).backupSession( eq( newSessionId ), eq( true ), anyString() );
}
代码示例来源:origin: magro/memcached-session-manager
@BeforeMethod
public void setUp() throws Exception {
_service = mock( MemcachedSessionService.class );
_request = mock( Request.class );
_response = mock( Response.class );
final Context _contextContainer = mock(Context.class);
final Host _hostContainer = mock(Host.class);
final SessionManager _manager = mock(SessionManager.class);
when(_service.getManager()).thenReturn(_manager);
when(_manager.getContext()).thenReturn(_contextContainer);
when(_contextContainer.getParent()).thenReturn(_hostContainer);
when(_contextContainer.getPath()).thenReturn("/");
_sessionTrackerValve = createSessionTrackerValve();
_nextValve = mock( Valve.class );
_sessionTrackerValve.setNext( _nextValve );
_sessionTrackerValve.setContainer(_hostContainer);
when(_request.getRequestURI()).thenReturn( "/someRequest");
when(_request.getMethod()).thenReturn("GET");
when(_request.getQueryString()).thenReturn(null);
when(_request.getContext()).thenReturn(_contextContainer);
when(_request.getNote(eq(RequestTrackingHostValve.REQUEST_PROCESSED))).thenReturn(Boolean.TRUE);
when(_request.getNote(eq(RequestTrackingHostValve.SESSION_ID_CHANGED))).thenReturn(Boolean.FALSE);
}
代码示例来源:origin: magro/memcached-session-manager
@Test
public void testInvalidNonStickySessionDoesNotCallOnBackupWithoutLoadedSessionIssue137() throws Exception {
_service.setStickyInternal( false );
_service.setLockingMode( LockingMode.NONE, null, false );
_service.startInternal(new MemcachedStorageClient(_memcachedMock)); // we must put in our mock again
final String sessionId = "nonStickySessionToTimeOut-n1";
// For findSession needed
final Request requestMock = mock(Request.class);
when(requestMock.getNote(eq(RequestTrackingContextValve.INVOKED))).thenReturn(Boolean.TRUE);
_service.getTrackingHostValve().storeRequestThreadLocal(requestMock);
final MemcachedBackupSession session = _service.findSession(sessionId);
assertNull(session);
_service.backupSession( sessionId, false, null ).get();
// check that validity info is not loaded - this would trigger the
// WARNING: Found no validity info for session id ...
final String validityKey = new SessionIdFormat().createValidityInfoKeyName( sessionId );
verify( _memcachedMock, times( 0 ) ).get( eq( validityKey ) );
}
代码示例来源:origin: magro/memcached-session-manager
/**
* {@inheritDoc}
*/
@Override
public void invoke( final Request request, final Response response ) throws IOException, ServletException {
final Object processRequest = request.getNote(RequestTrackingHostValve.REQUEST_PROCESS);
if(processRequest != Boolean.TRUE) {
request.setNote(INVOKED, Boolean.TRUE);
try {
getNext().invoke( request, response );
} finally {
request.setNote(RequestTrackingHostValve.REQUEST_PROCESSED, Boolean.TRUE);
}
}
else {
boolean sessionIdChanged = false;
try {
request.setNote(INVOKED, Boolean.TRUE);
sessionIdChanged = changeRequestedSessionId( request, response );
getNext().invoke( request, response );
} finally {
request.setNote(RequestTrackingHostValve.REQUEST_PROCESSED, Boolean.TRUE);
request.setNote(RequestTrackingHostValve.SESSION_ID_CHANGED, Boolean.valueOf(sessionIdChanged));
}
}
}
代码示例来源:origin: org.glassfish.main.security/websecurity
public Object getNote(String name) {
return httpRequest.getNote(name);
}
代码示例来源:origin: magro/memcached-session-manager
getNext().invoke( request, response );
} finally {
if(request.getNote(REQUEST_PROCESSED) == Boolean.TRUE) {
final String sessionId = getSessionId(request, response);
if(sessionId != null) {
getNext().invoke( request, response );
} finally {
final Boolean sessionIdChanged = (Boolean) request.getNote(SESSION_ID_CHANGED);
backupSession( request, response, sessionIdChanged == null ? false : sessionIdChanged.booleanValue() );
resetRequestThreadLocal();
代码示例来源:origin: magro/memcached-session-manager
when(requestMock.getNote(eq(RequestTrackingContextValve.INVOKED))).thenReturn(Boolean.TRUE);
_service.getTrackingHostValve().storeRequestThreadLocal(requestMock);
代码示例来源:origin: com.tomitribe.tribestream/tribestream-container
public static RequestContext fromRequest(final Request request) {
if (request == null) {
return null;
}
final Object requestContextObject = request.getNote(Constants.REQUEST_NOTE_PREFIX + Constants.REQUEST_NOTE_CONTEXT);
if (requestContextObject != null && RequestContext.class.isInstance(requestContextObject)) {
return RequestContext.class.cast(requestContextObject);
}
return null;
}
代码示例来源:origin: de.javakaffee.msm/memcached-session-manager
public boolean isIgnoredRequest() {
final Request request = _currentRequest.get();
return request != null && request.getNote(REQUEST_IGNORED) == Boolean.TRUE;
}
代码示例来源:origin: org.apache.tomee/tomee-catalina
public void onLogout(final HttpServletRequest request) {
final Request state = OpenEJBSecurityListener.requests.get();
final Object webappState = state == null ? null : state.getNote(TomEERealm.SECURITY_NOTE);
if (webappState != null) {
exitWebApp(webappState);
} else {
super.onLogout(request);
}
}
代码示例来源:origin: org.keycloak/keycloak-saml-tomcat-adapter-core
protected SamlSessionStore getSessionStore(Request request, HttpFacade facade, SamlDeployment resolvedDeployment) {
SamlSessionStore store = (SamlSessionStore)request.getNote(TOKEN_STORE_NOTE);
if (store != null) {
return store;
}
store = createSessionStore(request, facade, resolvedDeployment);
request.setNote(TOKEN_STORE_NOTE, store);
return store;
}
代码示例来源:origin: de.javakaffee.msm/memcached-session-manager
private String getSessionId(final Request request, final Response response) {
// If the context is configured with cookie="false" there's no session cookie
// sent so we must rely on data from MemcachedSessionService
String sessionId = (String) request.getNote(MemcachedSessionService.NEW_SESSION_ID);
if(sessionId == null) {
sessionId = getSessionIdFromResponseSessionCookie( response );
}
return sessionId != null ? sessionId : request.getRequestedSessionId();
}
代码示例来源:origin: org.glassfish.main.web/web-core
void track(Session localSession) {
validateRequest();
SessionTracker sessionTracker = (SessionTracker)
request.getNote(Globals.SESSION_TRACKER);
if (sessionTracker != null) {
sessionTracker.track(localSession);
}
}
代码示例来源:origin: org.keycloak/keycloak-tomcat-core-adapter
protected AdapterTokenStore getTokenStore(Request request, HttpFacade facade, KeycloakDeployment resolvedDeployment) {
AdapterTokenStore store = (AdapterTokenStore)request.getNote(TOKEN_STORE_NOTE);
if (store != null) {
return store;
}
if (resolvedDeployment.getTokenStore() == TokenStore.SESSION) {
store = createSessionTokenStore(request, resolvedDeployment);
} else {
store = new CatalinaCookieTokenStore(request, facade, resolvedDeployment, createPrincipalFactory());
}
request.setNote(TOKEN_STORE_NOTE, store);
return store;
}
代码示例来源:origin: org.keycloak/spring-boot-container-bundle
protected AdapterTokenStore getTokenStore(Request request, HttpFacade facade, KeycloakDeployment resolvedDeployment) {
AdapterTokenStore store = (AdapterTokenStore)request.getNote(TOKEN_STORE_NOTE);
if (store != null) {
return store;
}
if (resolvedDeployment.getTokenStore() == TokenStore.SESSION) {
store = createSessionTokenStore(request, resolvedDeployment);
} else {
store = new CatalinaCookieTokenStore(request, facade, resolvedDeployment, createPrincipalFactory());
}
request.setNote(TOKEN_STORE_NOTE, store);
return store;
}
内容来源于网络,如有侵权,请联系作者删除!