/// <summary> /// Inflate an object instance from the stream /// </summary> public bool Inflate(Stream source) { // Identifier of the feature TDSFeatureID featureID = TDSFeatureID.Terminator; // Iterate do { // Read the feature type featureID = (TDSFeatureID)source.ReadByte(); // Token being inflated TDSLogin7FeatureOptionToken optionToken = null; // skip this feature extension switch (featureID) { case TDSFeatureID.FederatedAuthentication: { // Federated authentication optionToken = new TDSLogin7FedAuthOptionToken(); break; } case TDSFeatureID.SessionRecovery: { // Session recovery optionToken = new TDSLogin7SessionRecoveryOptionToken(); break; } case TDSFeatureID.Terminator: { // Do nothing break; } default: { // Create a generic option optionToken = new TDSLogin7GenericOptionToken(featureID); break; } } // Check if we have an option token if (optionToken != null) { // Inflate it optionToken.Inflate(source); // Register with the collection Add(optionToken); // Update inflation offset InflationSize += optionToken.InflationSize; } }while (TDSFeatureID.Terminator != featureID); // We don't support continuation of inflation so report as fully inflated return(true); }
/// <summary> /// Ensure that federated authentication option is valid /// </summary> protected virtual TDSMessageCollection CheckFederatedAuthenticationOption(ITDSServerSession session, TDSLogin7FedAuthOptionToken federatedAuthenticationOption) { // Check if server's prelogin response for FedAuthRequired prelogin option is echoed back correctly in FedAuth Feature Extenion Echo if (federatedAuthenticationOption.Echo != (session as GenericTDSServerSession).FedAuthRequiredPreLoginServerResponse) { // Create Error message string message = string.Format("FEDAUTHREQUIRED option in the prelogin response is not echoed back correctly: in prelogin response, it is {0} and in login, it is {1}: ", (session as GenericTDSServerSession).FedAuthRequiredPreLoginServerResponse, federatedAuthenticationOption.Echo); // Create errorToken token TDSErrorToken errorToken = new TDSErrorToken(3456, 34, 23, message); // Log response TDSUtilities.Log(Arguments.Log, "Response", errorToken); // Create DONE token TDSDoneToken doneToken = new TDSDoneToken(TDSDoneTokenStatusType.Final | TDSDoneTokenStatusType.Error); // Log response TDSUtilities.Log(Arguments.Log, "Response", doneToken); // Build a collection with a single message of two tokens return new TDSMessageCollection(new TDSMessage(TDSMessageType.Response, errorToken, doneToken)); } // Check if the nonce exists if ((federatedAuthenticationOption.Nonce == null && federatedAuthenticationOption.Library == TDSFedAuthLibraryType.IDCRL) || !AreEqual((session as GenericTDSServerSession).ServerNonce, federatedAuthenticationOption.Nonce)) { // Error message string message = string.Format("Unexpected NONCEOPT specified in the Federated authentication feature extension"); // Create errorToken token TDSErrorToken errorToken = new TDSErrorToken(5672, 32, 87, message); // Log response TDSUtilities.Log(Arguments.Log, "Response", errorToken); // Create DONE token TDSDoneToken doneToken = new TDSDoneToken(TDSDoneTokenStatusType.Final | TDSDoneTokenStatusType.Error); // Log response TDSUtilities.Log(Arguments.Log, "Response", doneToken); // Build a collection with a single message of two tokens return new TDSMessageCollection(new TDSMessage(TDSMessageType.Response, errorToken, doneToken)); } // We're good return null; }