networksecurity/tls/protocol/AlertProtocolEvents.cpp
changeset 69 955592283707
parent 0 af10295192d8
equal deleted inserted replaced
66:34ec136802c5 69:955592283707
   122 				
   122 				
   123 				return NULL; //stop the state machine
   123 				return NULL; //stop the state machine
   124 			}
   124 			}
   125 		case KErrSSLAlertCloseNotify:
   125 		case KErrSSLAlertCloseNotify:
   126 			{
   126 			{
       
   127 			    if ( iStateMachine->iStatus.Int() == KRequestPending ||
       
   128 			            iRecordComposer.CurrentPos() != 0 ||
       
   129 			            iRecordComposer.UserData()!= NULL )
       
   130 			        {
       
   131 			        LOG(Log::Printf(_L("Previous data send request is in the pending state"));)
       
   132 			        return this;
       
   133 			        }
   127 				//Upon sending the close_notify from server report KErrEof to the application 
   134 				//Upon sending the close_notify from server report KErrEof to the application 
   128 				//to be intact with existing behaviour.	
   135 				//to be intact with existing behaviour.	
   129 				iStateMachine->SetLastError( KErrEof );
   136 				iStateMachine->SetLastError( KErrEof );
   130 				iAlertMsg.Append( EAlertWarning );
   137 				iAlertMsg.Append( EAlertWarning );
   131 				iAlertMsg.Append( EAlertclose_notify );
   138 				iAlertMsg.Append( EAlertclose_notify );
   151             break;
   158             break;
   152          }
   159          }
   153 		case KErrCancel:
   160 		case KErrCancel:
   154 			{// A user_canceled alert should be followed by a close_notify alert. So this
   161 			{// A user_canceled alert should be followed by a close_notify alert. So this
   155 			 // event will be the next one to be processed. 
   162 			 // event will be the next one to be processed. 
   156 				iRecordComposer.SetNext( NULL );
       
   157 				iAlertMsg.Append( EAlertWarning );
   163 				iAlertMsg.Append( EAlertWarning );
   158 				iAlertMsg.Append( EAlertclose_notify );
   164 				iAlertMsg.Append( EAlertclose_notify );
   159 				iRecordComposer.SetNext( NULL );
   165 				iRecordComposer.SetNext( NULL );
   160             break;
   166             break;
   161 			}
   167 			}
   196 	TUint8 alertLevel = alertMsg[0];
   202 	TUint8 alertLevel = alertMsg[0];
   197 	TUint8 alertDesc = alertMsg[1];
   203 	TUint8 alertDesc = alertMsg[1];
   198 	LOG(Log::Printf(_L("CRecvAlert::ProcessL(). Alert level = %d"), alertLevel ));
   204 	LOG(Log::Printf(_L("CRecvAlert::ProcessL(). Alert level = %d"), alertLevel ));
   199 	LOG(Log::Printf(_L("CRecvAlert::ProcessL(). Alert description = %d"), alertDesc ));
   205 	LOG(Log::Printf(_L("CRecvAlert::ProcessL(). Alert description = %d"), alertDesc ));
   200 
   206 
       
   207 	if ( alertLevel == EAlertFatal )
       
   208 	    {
   201 	TRequestStatus* p=&aStatus;
   209 	TRequestStatus* p=&aStatus;
   202 	User::RequestComplete( p, KErrNone );
   210 	    User::RequestComplete( p, KErrSSLAlertHandshakeFailure );
   203 	if ( alertLevel == EAlertWarning )
   211 	    iStateMachine->SetLastError( KErrSSLAlertHandshakeFailure );
       
   212 	    }
       
   213 	else if ( alertLevel == EAlertWarning )
   204 	   {// In all circumstances, when a warning alert is received, we carry on as normal.
   214 	   {// In all circumstances, when a warning alert is received, we carry on as normal.
   205 		// There is no need to set the next event as this will be unchanged from normal
   215 		// There is no need to set the next event as this will be unchanged from normal
   206 		// operation. For a Close_notify alert, we must send one in response.
   216 		// operation. For a Close_notify alert, we must send one in response.
   207 		// So the next event will be CSendAlert sending a close-notify alert.
   217 		// So the next event will be CSendAlert sending a close-notify alert.
       
   218 	    TRequestStatus* p=&aStatus;
       
   219 	    User::RequestComplete( p, KErrNone );
   208       if ( alertDesc == EAlertclose_notify )
   220       if ( alertDesc == EAlertclose_notify )
   209          {
   221          {
   210          iStateMachine->SetLastError( KErrSSLAlertCloseNotify );
   222          iStateMachine->SetLastError( KErrSSLAlertCloseNotify );
   211          return &iSendAlert;
   223          return &iSendAlert;
   212          }
   224          }