Ejemplo n.º 1
0
 void assertMaxRelError(
     const T& expected,
     const T& actual,
     double maxRelativeError,
     const std::string sourceFile,
     const std::string sourceLine)
 {
     CPPUNIT_ASSERT_MESSAGE( failureMessage(sourceFile,
                                            sourceLine,
                                            wns::to<std::string>(expected),
                                            wns::to<std::string>(actual)),
                             std::fabs(expected - actual) <= std::abs(expected * maxRelativeError) );
 }
Ejemplo n.º 2
0
void CPppMsChap::FailureL(RMBufPacket& aPacket)
/**
   @copydoc CPppChap::FailureL(RMBufPacket&)
   @see CPppChap::FailureL(RMBufPacket&)
   @internalComponent
*/
	{
	__ASSERT_ALWAYS(aPacket.Length() >= KPppChapCodeFieldSize +
					KPppChapIdFieldSize + 
					KPppChapLengthFieldSize ,
			User::Leave(KErrUnderflow));
	if (!CheckIdentifier(aPacket))
		User::Leave(KErrGeneral);

	TimerCancel();

	TPtrC8 failureMessage(aPacket.First()->Ptr() +
					KPppChapCodeFieldSize + 
					KPppChapIdFieldSize +
					KPppChapLengthFieldSize, 
				aPacket.Length() -
					KPppChapCodeFieldSize - 
					KPppChapIdFieldSize -
					KPppChapLengthFieldSize);

	if (failureMessage.Length()==0)
		{
		DoFail(KErrIfAuthenticationFailure);
		return;
		}

	TUint msChapError;
	TUint8 isRetryAllowed;
	TUint8 passwordProtoVersion;
	TBool hasNewChallenge;
	TInt sysError = KErrIfAuthenticationFailure;

	ProcessFailureMessageL(failureMessage, 
				msChapError,
				isRetryAllowed, 
				hasNewChallenge, 
				iChallengeRef,
				passwordProtoVersion);

	sysError = TranslateMsChapError(msChapError);

#ifndef __MS_CHAP_WITH_LAN_MANAGER__

// The authenticator-controlled authentication retry mechanisms and
// the password changing mechanisms have not been implemented in this
// release - this is in accordance with the project requirements.
// Consequently simply fail.

	DoFail(sysError);

#else // __MS_CHAP_WITH_LAN_MANAGER__

// The code only handles KPppMsChapAuthenticationFailure, and no other
// MS-CHAP specific errors.  In particular, this code does not handle
// KPppMsChapErrorPasswordExpired, since the password changing
// mechanisms have not been implemented in this release - this is in
// accordance with the project requirements.
	if (msChapError != KPppMsChapAuthenticationFailure)
		{
		DoFail(sysError);
		return;
		}

	if (!isRetryAllowed)
		{
		DoFail(sysError);
		return;
		}

	if (!hasNewChallenge)
		iChallengeRef[0] += 23; // magic constant from RFC 2433


	if(!iUseNTResponse)
		{
// Has already retried authentication using a LAN Manager compatible
// Challenge Response.  Have tried Microsoft Windows NT compatible
// Challenge Response and LAN Manager compatible Challenge Response,
// so fail now
		iUseNTResponse = ETrue;
		DoFail(sysError);
		return;
		}

// Retry authentication using a LAN Manager compatible Challenge
// Response.
	iUseNTResponse = EFalse;

	RetryPasswordL();

#endif //  __MS_CHAP_WITH_LAN_MANAGER__
	}
Ejemplo n.º 3
0
void CPppMsChap2::FailureL(RMBufPacket& aPacket)
/**
   @copydoc CPppChap::FailureL(RMBufPacket&)
   @see CPppChap::FailureL(RMBufPacket&)
   @internalComponent
*/
{
    __ASSERT_ALWAYS(aPacket.Length() >= KPppChapCodeFieldSize +
                    KPppChapIdFieldSize +
                    KPppChapLengthFieldSize +
                    KPppMsChap2AuthenticatorChallengeSize*2
                    + 2,
                    User::Leave(KErrUnderflow));

// check the id
    if (!CheckIdentifier(aPacket))
        User::Leave(KErrGeneral);

    TimerCancel();

#ifndef _DEBUG

// The authenticator-controlled authentication retry mechanisms and
// the password changing mechanisms have not been implemented in this
// release - this is in accordance with the project requirements.
// Consequently simply fail.

    DoFail(KErrIfAuthenticationFailure);

#else // _DEBUG

// Read the length of the MS-CHAP-V2 Failure packet and compute the
// length of the CHAP Message field and go past the CHAP Code field,
// the CHAP Identifier field and the CHAP Length field, in order to
// read the CHAP Message field
    TPtrC8 failureMessage(aPacket.First()->Ptr() +
                          KPppChapCodeFieldSize +
                          KPppChapIdFieldSize +
                          KPppChapLengthFieldSize,
                          aPacket.Length() -
                          KPppChapCodeFieldSize -
                          KPppChapIdFieldSize -
                          KPppChapLengthFieldSize);

    if (failureMessage.Length()==0)
    {
        DoFail(KErrIfAuthenticationFailure);
        return;
    }

    TUint msChapError;
    TUint8 isRetryAllowed;
    TUint8 passwordProtoVersion;
    TPtrC8 message;
    TInt sysError=KErrIfAuthenticationFailure;

    ProcessFailureMessageL(failureMessage,
                           msChapError,
                           isRetryAllowed,
                           iChallengeRef,
                           passwordProtoVersion,
                           message);

    sysError=TranslateMsChapError(msChapError);

// The code only handles KPppMsChapAuthenticationFailure, and no other
// MS-CHAP specific errors.  In particular, this code does not handle
// KPppMsChapErrorPasswordExpired, since the password changing
// mechanisms have not been implemented in this release - this is in
// accordance with the project requirements.
    if (msChapError != KPppMsChapAuthenticationFailure)
    {
        DoFail(sysError);
        return;
    }

    if (!isRetryAllowed)
    {
        DoFail(sysError);
        return;
    }

// The authenticator-controlled authentication retry mechanisms and
// the password changing mechanisms have not been implemented in this
// release - this is in accordance with the project requirements.
// Consequently simply fail.
    DoFail(sysError);

#endif // _DEBUG
}