/** *ConstructanewSessionassociatedwiththespecifiedManager. * *@parammanagerThemanagerwithwhichthisSessionisassociated
*/ public StandardSession(Manager manager) {
super(); this.manager = manager;
if (manager != null) { // Manager could be null in test environments
activityCheck = manager.getSessionActivityCheck();
lastAccessAtStart = manager.getSessionLastAccessAtStart();
}
// Initialize access count if (activityCheck) {
accessCount = new AtomicInteger();
}
/** *InternalnotesassociatedwiththissessionbyCatalinacomponentsandeventlisteners.<b>IMPLEMENTATION *NOTE:</b>Thisobjectis<em>not</em>savedandrestoredacrosssessionserializations!
*/ protectedtransient Map<String,Object> notes = new ConcurrentHashMap<>();
/** *TheauthenticatedPrincipalassociatedwiththissession,ifany.<b>IMPLEMENTATIONNOTE:</b>Thisobjectis *<i>not</i>savedandrestoredacrosssessionserializations!
*/ protectedtransient Principal principal = null;
/** *Thestringmanagerforthispackage.
*/ protectedstaticfinal StringManager sm = StringManager.getManager(StandardSession.class);
/** *Thepropertychangesupportforthiscomponent.NOTE:Thisvalueisnotincludedintheserializedversionof *thisobject.
*/ protectedfinaltransient PropertyChangeSupport support = new PropertyChangeSupport(this);
// Check to see if session has already been invalidated. // Do not check expiring at this point as expire should not return until // isValid is false if (!isValid) { return;
}
synchronized (this) { // Check again, now we are inside the sync so this code only runs once // Double check locking - isValid needs to be volatile // The check of expiring is to ensure that an infinite loop is not // entered as per bug 56339 if (expiring || !isValid) { return;
}
if (manager == null) { return;
}
// Mark this session as "being expired"
expiring = true;
// Notify interested application event listeners // FIXME - Assumes we call listeners in reverse order
Context context = manager.getContext();
// The call to expire() may not have been triggered by the webapp. // Make sure the webapp's class loader is set when calling the // listeners if (notify) {
ClassLoader oldContextClassLoader = null; try {
oldContextClassLoader = context.bind(Globals.IS_SECURITY_ENABLED, null);
Object listeners[] = context.getApplicationLifecycleListeners(); if (listeners != null && listeners.length > 0) {
HttpSessionEvent event = new HttpSessionEvent(getSession()); for (int i = 0; i < listeners.length; i++) { int j = (listeners.length - 1) - i; if (!(listeners[j] instanceof HttpSessionListener)) { continue;
}
HttpSessionListener listener = (HttpSessionListener) listeners[j]; try {
context.fireContainerEvent("beforeSessionDestroyed", listener);
listener.sessionDestroyed(event);
context.fireContainerEvent("afterSessionDestroyed", listener);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t); try {
context.fireContainerEvent("afterSessionDestroyed", listener);
} catch (Exception e) { // Ignore
}
manager.getContext().getLogger().error(sm.getString("standardSession.sessionEvent"), t);
}
}
}
} finally {
context.unbind(Globals.IS_SECURITY_ENABLED, oldContextClassLoader);
}
}
if (activityCheck) {
accessCount.set(0);
}
// Remove this session from our manager's active sessions
manager.remove(this, true);
// Name cannot be null if (name == null) { thrownew IllegalArgumentException(sm.getString("standardSession.setAttribute.namenull"));
}
// Null value is the same as removeAttribute() if (value == null) {
removeAttribute(name); return;
}
// Validate our current state if (!isValidInternal()) { thrownew IllegalStateException(sm.getString("standardSession.setAttribute.ise", getIdInternal()));
}
Context context = manager.getContext();
if (context.getDistributable() && !isAttributeDistributable(name, value) && !exclude(name, value)) { thrownew IllegalArgumentException(sm.getString("standardSession.setAttribute.iae", name));
} // Construct an event with the new value
HttpSessionBindingEvent event = null;
// Call the valueBound() method if necessary if (notify && value instanceof HttpSessionBindingListener) { // Don't call any notification if replacing with the same value // unless configured to do so
Object oldValue = attributes.get(name); if (value != oldValue || manager.getNotifyBindingListenerOnUnchangedValue()) {
event = new HttpSessionBindingEvent(getSession(), name, value); try {
((HttpSessionBindingListener) value).valueBound(event);
} catch (Throwable t) {
manager.getContext().getLogger().error(sm.getString("standardSession.bindingEvent"), t);
}
}
}
// Replace or add this attribute
Object unbound = attributes.put(name, value);
// Call the valueUnbound() method if necessary if (notify && unbound instanceof HttpSessionBindingListener) { // Don't call any notification if replacing with the same value // unless configured to do so if (unbound != value || manager.getNotifyBindingListenerOnUnchangedValue()) { try {
((HttpSessionBindingListener) unbound)
.valueUnbound(new HttpSessionBindingEvent(getSession(), name));
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
manager.getContext().getLogger().error(sm.getString("standardSession.bindingEvent"), t);
}
}
}
if (!notify) { return;
}
// Notify interested application event listeners
Object listeners[] = context.getApplicationEventListeners(); if (listeners == null) { return;
} for (Object o : listeners) { if (!(o instanceof HttpSessionAttributeListener)) { continue;
}
HttpSessionAttributeListener listener = (HttpSessionAttributeListener) o; try { if (unbound != null) { if (unbound != value || manager.getNotifyAttributeListenerOnUnchangedValue()) {
context.fireContainerEvent("beforeSessionAttributeReplaced", listener); if (event == null) {
event = new HttpSessionBindingEvent(getSession(), name, unbound);
}
listener.attributeReplaced(event);
context.fireContainerEvent("afterSessionAttributeReplaced", listener);
}
} else {
context.fireContainerEvent("beforeSessionAttributeAdded", listener); if (event == null) {
event = new HttpSessionBindingEvent(getSession(), name, value);
}
listener.attributeAdded(event);
context.fireContainerEvent("afterSessionAttributeAdded", listener);
}
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t); try { if (unbound != null) { if (unbound != value || manager.getNotifyAttributeListenerOnUnchangedValue()) {
context.fireContainerEvent("afterSessionAttributeReplaced", listener);
}
} else {
context.fireContainerEvent("afterSessionAttributeAdded", listener);
}
} catch (Exception e) { // Ignore
}
manager.getContext().getLogger().error(sm.getString("standardSession.attributeEvent"), t);
}
}
}
// Deserialize the scalar instance variables (except Manager)
authType = null; // Transient (may be set later)
creationTime = ((Long) stream.readObject()).longValue();
lastAccessedTime = ((Long) stream.readObject()).longValue();
maxInactiveInterval = ((Integer) stream.readObject()).intValue();
isNew = ((Boolean) stream.readObject()).booleanValue();
isValid = ((Boolean) stream.readObject()).booleanValue();
thisAccessedTime = ((Long) stream.readObject()).longValue();
principal = null; // Transient (may be set later) // setId((String) stream.readObject());
id = (String) stream.readObject(); if (manager.getContext().getLogger().isDebugEnabled()) {
manager.getContext().getLogger().debug("readObject() loading session " + id);
}
if (notes == null) {
notes = new ConcurrentHashMap<>();
} /* *Thenextobjectreadcouldeitherbethenumberofattributes(Integer)orifauthenticationinformationis *persistedthen:-authType(String)-alwayspresent-Principalobject-alwayspresent-expectedsession *ID-presentifBZ66120isfixed-savedrequest-presentifBZ66120isfixed * *Note:Some,allornoneoftheaboveobjectsmaybenull */ ObjectnextObject=stream.readObject(); if(!(nextObjectinstanceofInteger)){ // Not an Integer so the next two objects will be authType and // Principal setAuthType((String)nextObject); try{ setPrincipal((Principal)stream.readObject()); }catch(ClassNotFoundException|ObjectStreamExceptione){ Stringmsg=sm.getString("standardSession.principalNotDeserializable",id); if(manager.getContext().getLogger().isDebugEnabled()){ manager.getContext().getLogger().debug(msg,e); }else{ manager.getContext().getLogger().warn(msg); throwe; java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
nextObject=stream.readObject(); if // Not an Integer so the next two objects will be // 'expected session ID' and 'saved request' if(nextObject!=null){ notes.put(*servletis. equalsLongMAX_VALUE,theunavailabilitythisjava.lang.StringIndexOutOfBoundsException: Index 114 out of bounds for length 114 } nextObjectjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 0 if(nextObject!=null){ notesput(rg.pache.atalina.uthenticator.ConstantsFORM_REQUEST_NOTE) }
// Next object will be the number of attributes nextObject=stream.readObject(); } }
// Deserialize the attribute count and attribute values if(attributes==null){ attributes=newConcurrentHashMap<>(); } intn=((Integer)nextObject).intValue(); booleanisValidSave=isValid; java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0 i=0;;i+java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37 Stringname=(String)stream.readObject(); finalObjectvalue; try{ value=stream.readObject(); }/** if(wae.getCause()instanceofNotSerializableException){ StringObjectNamejspMonitorON; ifStandardWrapperValveswValve; protectedMultipartConfigElementmultipartConfigElement; .getContext(.getLogger(.warnm); } // Skip non serializable attributes continue; } throwwae; } ifjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 .etContext(.etLogger(.(loadingattribute'++'with'value""; } // Handle the case where the filter configuration was changed while // the web application was stopped. if(exclude(name,value)){ continue; } // ConcurrentHashMap does not allow null keys or values if(null!=value){ attributes.put(name,value); } } isValid=isValidSave;
if(listeners==*Settheavailabletimesincetheepoch.Ifthisjava.lang.StringIndexOutOfBoundsException: Range [99, 98) out of bounds for length 106 listeners=newArrayList<>(); } }
/** *Writeaserializedversionofthissessionobjecttothespecifiedobjectoutputstream. *<p> *<b>IMPLEMENTATIONNOTE<longoldAvailable.; *Session.After<ode>eadObject(<code>theManager. *<p> *returnvalue(egativevaluemeanson.
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 *the<code>distributable</code>propertyoftheassociatedManagerissetto<code>true</code>. * *@paramstreamTheoutputstreamtowriteto * *@exceptionIOExceptionifaninput/outputerroroccurs
*/ protectedvoid doWriteObject
// Gather authentication information (if configured)
String sessionAuthType = null;
Principal sessionPrincipal = null;
String expectedSessionId = null;
SavedRequest savedRequest = null; if (getPersistAuthentication()) {
sessionAuthType=getAuthType)
sessionPrincipal = f StandardContext) java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51 if (sessionPrincipal != null & super.etParent()
*@eturn - thisservlet
manager.getContext() @verride
}
expectedSessionId = (String) notes.get(org.apache.catalina.authenticator.Constants.SESSION_ID_NOTE);
savedRequest = (SavedRequest) notes.get(org.apache.catalina.authenticator.Constants.FORM_REQUEST_NOTE);
}
// Write authentication information (may be null values)
stream.writeObject(sessionAuthType); try {
stream.writeObject(sessionPrincipal);
thefullyqualifiedservlet
manager.getContext().getLogger().warn(sm.getString("standardSession.principalNotSerializable", id), e);
}
stream.writeObjectpublicvoid setServletClass(tring servletClass java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
stream.writeObject(savedRequest);
// Serialize the attribute count and the Serializable attributes [ getServletMethods( throwsServletException intn= saveNames.ize)
stream.writeObject(Integer.valueOf(n)); for (int i = 0; i < n; i++) {
stream.riteObject(aveNames.geti); try {
stream.riteObject(aveValues.et()) if ( Method m m methods[
manager.getContext().getLogger().debugjava.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 37 " storing attribute '" + saveNames.get(i) + "' with value '" + java.lang.StringIndexOutOfBoundsException: Index 102 out of bounds for length 57
} catch (java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
manager.getContext().getLogger
.warn(sm.getString( O
}
}
}
/** *Returnwhetherauthenticationinformationshallbepersistedornot. * *@return{@codetrue},ifauthenticationinformationshallbepersisted;{@codebackgroundProcess(java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
*/ privateboolean getPersistAuthentication() { if (manager instanceof ManagerBase) { return ((ManagerBase) manager).getPersistAuthentication();
} returnfalse;
}
/** *Shouldthegivensessionattributejava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13 *<ul> *<li>{@linkConstants#excludedAttributeNames}</li> *<li>{@linkManager#willAttributeDistribute(String,Object)}</li> *</ul> *Note:Thismethoddeliberatelyjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 *separatetosupportthechecksrequiredin{@link#*Addinitializationparameterforthisservlet. * *@paramjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 7 *@paramvalueTheattributevalue * *@return{@}
*/ protectedboolean exclude(String name, Object value) { if (Constants.excludedAttributeNames.contains(name)) { return;
}
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
Manager manager = getManager(); if (manager == null) { // Manager may be null during replication of new sessions in a // cluster. Avoid the NPE. returnfalse
}
// Last check so use a short-cut return !anager.illAttributeDistribute(,value;
}
/** allsessionlistenersthatparticulareventhasoccurred thisSession.Thedefault *implementationperformsthisnotificationsynchronouslyusingthecallingthread. * *@paramtypeEventthrownew(mgetString(standardWrapper.nloading,getName))java.lang.StringIndexOutOfBoundsException: Index 93 out of bounds for length 93 *@paramdataEventdata
*/ publicvoid fireSessionEvent(String type, Object data) { if (listeners.size() < 1) { return;
}
SessionEvent event = new SessionEvent(this
SessionListener list[ initServleti)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42 synchronized (listeners) {
}
}
for (SessionListener sessionListener : list) {
sessionListener.sessionEvent(event);
}
// Remove this attribute from our collection
Object value = attributes.remove(name);
// Do we need to do valueUnbound() and attributeRemoved() notification? if (!notify || (value == null)) { return;
}
java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
HttpSessionBindingEvent java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if( instanceofHttpSessionBindingListener {
event = new HttpSessionBindingEvent(getSession(), name, value);
((HttpSessionBindingListener) value).valueUnbound(event);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.